简体   繁体   中英

Solr exact match field boosting

I have this requirement: if the query text match exactly with a particular field value (the title field) the result must be first or al least be boosted. So I need to boost the results with the exact match.

My solution is to create the title as an untokenized field, so it'll match only exactly, and boost this the title with an edismax query.

Is there any othere way? How can I index a field untokenized? So without tokenize on spaces?

Use a KeywordTokenizer - this will index the field as a single value, but still allow you to attach filters - for example to lowercase the text before storing the token.

If you don't want to perform lowercasing either, you can use a string (StrField) field - a string field will only give a hit if the value is exactly the same.

This is usually what you'll do to give exact hits a larger boost than other hits - and you can use the qf parameter to dismax (which you probably are already) to give this list. Use copyField to index the content into separate fields with different definitions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM