graphql-text-search

A graphql server for providing text search capability

Overview

This is implementation of a graphql + apollo powered server to provide subtextsearch capabilities. The text and subtext to search is provided from two rest endpoints.

System Requirements

  • node
  • yarn/ npm

How To Use

  • yarn install
  • docker-compose up
  • yarn start
  • Search for subtexts in a text:
    var request = require("request");
    
    var options = {
      method: 'POST',
      url: 'http://localhost:4000/',
      headers: {'content-type': 'application/json'},
      body: '{"query":"{\n  searchResult {\n    text {text}\n    subtext {subtexts}\n    results {\n      subtext\n      result\n    }\n  }\n}\n"}'
    };
    
    request(options, function (error, response, body) {
      if (error) throw new Error(error);
    
      console.log(body);
    });
    
    
  • Submit result (mutation):
    var request = require("request");
    
    var options = {
      method: 'POST',
      url: 'http://localhost:4000/',
      headers: {'content-type': 'application/json'},
      body: '{"query":"mutation {submitResults(results: {\n  candidate: \"sush\"\n  text: \"some text\"\n  results: [\n        {\n          subtext: \"so\",\n          result: \"0\"\n        },\n        {\n          subtext: \"te\",\n          result: \"5\"\n        }\n  ]\n})}"}'
    };
    
    request(options, function (error, response, body) {
      if (error) throw new Error(error);
    
      console.log(body);
    });
    

Implementation Details