Search code examples
elasticsearchbert-language-modelnlp-question-answeringhaystack

Custom query with Deepstackai haystack


I am exploring deepset haystack and found it very interesting for multiple use cases like a chatbot, search engine, document search, etc

But have not found any reference where I can create multiple indexes for different documents and search based on indexes. I thought of using meta tags for conditional search(on a particular area) by tagging the documents first and then using the params parameter of query API but the same doesn't seem to work and throws an error(I used its vanilla docker-compose based setup)

enter image description here


Solution

  • You can use multiple indices in the same document store if you want to support multiple use cases, indeed. The write_documents method of the document store has a parameter index so that you can store documents for your different use cases in different indices. In the same way, you can pass an index parameter to the query method.

    As you expected, there is an alternative solution that uses the meta field of documents. However, the format needs to be slightly different. Your query needs to have the following format:

    {"query": "What's the capital town?", "params": {"filters": {"name": "75_Algeria75.txt"}}}
    

    and your documents need to have the following format:

    {'text': 'Algeria is...', 'meta':{'name': "75_Algeria75.txt"}}