1

I am indexing and searching 5 fields, which are tokenized/filtered in various ways.
BUT, I would like that when I search, if the query I entered matches a value in field 1, it will be the top result I get back.
How would I define:

  1. The field
  2. The query in such a way this field gets priority IF there is 100% match

In my schema, I have the field

<field name="na_title" type="text_names" indexed="true" stored="false" required="true" />

text_names is :<fieldType name="text_names" class="solr.StrField" />

I have ONLY one entry with na_title="somthing is going on here". But, when I search text_names:somthing is going on here I get many results.
Just to point it out, there are no analyzers nor filters on that field, both for query and index actions.

Itay Moav -Malimovka
  • 52,579
  • 61
  • 190
  • 278

2 Answers2

1

From the manual:

Lucene allows influencing search results by "boosting" in more than one level:

  • Document level boosting - while indexing - by calling document.setBoost() before a document is added to the index.
  • Document's Field level boosting - while indexing - by calling field.setBoost() before adding a field to the document (and before adding the document to the index).
  • Query level boosting - during search, by setting a boost on a query clause, calling Query.setBoost().
mindas
  • 26,463
  • 15
  • 97
  • 154
1

You'll need to index the field twice -- once analyzed and once not. Then you can boost the matches in the nonanalyzed fields over the others.

A shortcut could be to index all those fields as strings and use copyfield to copy them as text into a catch-all field. That would simplify the query a little and decrease the number of duplicate fields.

Mike R.
  • 558
  • 2
  • 4
  • Do the additional results contain any part of your query or are they just random documents? I would run that string through the analysis page and make sure that is truly is unanalyzed. Also, debugQuery might shed some light on where those extra results are coming from. – Mike R. Sep 28 '12 at 22:44
  • 1
    Solution here woks, saw that before your comment...http://stackoverflow.com/questions/2630879/solr-exact-word-search – Itay Moav -Malimovka Sep 28 '12 at 22:48