1

I have to make query to Apache Solr, like this:

name:ABCXYZ AND address:Ame*

I find that the the query with just name:ABCXYZ receives a quick response, with only 1 result. However, the response time is much higher for the query above, which includes a second field, address.

How can I tune Solr, or my query, so that it prioritizes the search for each field? In my case, this would mean to search name before address.

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Thien Dinh
  • 373
  • 1
  • 6
  • 15

2 Answers2

2

"name:ABCXYZ" gives an answer straight away, because the query is very specific and yields one distinct result. Normally you would expect a query like "name:ABCXYZ AND address:Ame*" to find all entries where name is ABCXYZ, then further find entries where address starts with "Ame".

The thing about Solr is that it is possible to configure it in such a way that even though "name:ABCXYZ AND address:Ame*" only yields one result, solr will continue to search for other entries that doesn't match the entire query string, but matches part of string.

This means that perhaps your search is too "kind"?

We use a query parameter named "mm" (Minimum Match) which you can set on your search handler in solrconfig.xml. This parameter specifies the minimum number of clauses that the query must match. So if mm=1 for instance, your query will find entries where name is "ABCXYZ', but also adresses that start with "Ame". Maybe you should look into this mm parameter? It's possible to set mm=100% which should force your search handler to find exact matches I imagine.

Edit: "mm" is for DisMax Query Parsers by the way.

Brumlebarten
  • 686
  • 6
  • 6
  • I'm using SolrCloud, do I have to restart Solr instance or just have to upload new solrConfig.xml? – Thien Dinh Apr 05 '16 at 08:18
  • That I don't know, but according to http://stackoverflow.com/questions/8126419/updates-to-solrconfig-xml-file-are-not-being-reflected it seems like you have to restart the Solr instance. – Brumlebarten Apr 05 '16 at 11:17
  • Do I have to re-index? It's seem to not work for me, the response time is still high. – Thien Dinh Apr 05 '16 at 11:23
  • It seems like I misunderstood your question. The answer that I gave is about how the query result is sorted, where hits on id has the highest priority and so on. I will update my answer. – Brumlebarten Apr 05 '16 at 11:32
1

search name before address

name:ABCXYZ^10 OR address:Ame^6

assigns name a boost of 10, and address a boost of 7. These boost factors make matches in name much more significant than matches in address