solrlucenefull-text-searchpysolr

Solr text search not working with long queries


I'm not an expert in Solr and I'm trying it to check it's capabilities.

I'm having this odd behaviour where I'm getting good results if my text search query is composed of max 3 words, and zero results if the query is bigger.

What I did:

  1. Created a docker with solr and core named my_core:

    docker run -d -p 8983:8983 --name my_solr solr solr-precreate my_core

  2. In the dashboard created a new Field, named campo_teste, with the type text_pt because I need to index a dataset of Portuguese texts.

  3. Added and indexed my corpus with pysolr.

  4. Now at query time, when I search for "subsídio de parentalidade" I get results that make sense:

enter image description here

  1. But if I use a longer sentences I get zero results. This is an example with the same query as before but in the longer sentence "quando posso pedir o subsídio de parentalidade?":

enter image description here

Any ideas of what might be causing this issue?


Solution

  • You're not searching in the same field for all your values; in the first example you're searching for subsídio in the campo_text field and de parentalidade in the default search field (since you didn't prefix those values with a field name).

    In your second example you're searching for quando in the campo_text field and posso pedir o subsídio de parentalidade in the default search field (since you're not prefixing those values).

    In effect, subsídio is present in campo_text, while quando is not - the default search field (by default _text_) probably has no content, so no hits are produced.

    If you want to support general user queries, it's usually a better idea to use the edismax query handler with the qf (query fields) setting:

    q=quanto posso pedir o subsídio de parentalidade&defType=edismax&qf=campo_text
    

    This will search campo_text using all the words. You can then use q.op=AND or q.op=OR to adjust whether all words needs to be present or not, or you can use mm (minimum match) to adjust the profile in a more detailed way.