solrsolr-query-syntax

Search documents by multiple words query in Solr


I have the documents

[
  { "id": 1, "title": "next notebook" },
  { "id": 2, "title": "next thing" }
]

The title field type is

<fieldType name="managed_en" positionIncrementGap="100" class="solr.TextField">
  <analyzer type="index">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.ManagedStopFilterFactory" managed="english" />
    <filter class="solr.ManagedSynonymGraphFilterFactory" managed="english" />
    <filter class="solr.FlattenGraphFilterFactory"/> <!-- required on index analyzers after graph filters -->
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.ManagedStopFilterFactory" managed="english" />
    <filter class="solr.ManagedSynonymGraphFilterFactory" managed="english" />
  </analyzer>
</fieldType>

And I am trying to search next thing, so the request is /select?q=title%20next%20thing

I expect that document with id: 2 will be on top, but the order is same as they were added, and the score is the same 0.3979403

How should be the query to achieve that if more words from query are in the title, than the document shoud be in the top?


Solution

  • this query is searching the default search field (df) for title, next, and thing %20 is a space character.

    q=title%20next%20thing

    try something like q=next%20thing&df=title