Solr: promotion based on the existence of a field, disregarding that field content

I would like to augment a query based on the existence of a field in the document, regardless of the content of that field. Let's say a document has a field that contains a photo ID value, and I would like documents that first come to a search come to a search.

The photo ID value will not be relevant to the search term, but the presence of this field will do. How to do it?


source to share

1 answer

As described here , field:[* TO *]

will match all documents with the field and can be used by you to improve.

With DisMax bq

can be used to boost as described here . Add <str name="bq">field:[* TO *]^10</str>

to requestHandler insolrconfig.xml

Please note that the above does not guarantee that all documents with photos will appear at the top, followed by documents that have no photos. However, I think the above should work well for your use case - try it and let me know if you really want a guaranteed, absolute order.



All Articles