简体   繁体   中英

How to blacklist/demote search results with certain set of keywords in ElasticSearch and Apache Solr?

I was comparing both ElasticSearch and Apache Solr for a search solution. Data that will go into the system is not moderated and I don't want anyone to search for something and some sexually explicit content to flash on the very top of the search result. But I don't want to remove them for search results either. I want to demote them, so that they come later in the search results. Can I do this in Solr or ElasticSearch ? Some pointers towards how to achieve this will be helpful.

In Solr you can't give "negative boosts" per se but you can boost everything that doesn't have the term. This can be done with the boost query:

...&bq=(*:* -erotic)^999

or in solrconfig.xml:

<str name="bq">(*:* -erotic)^999</str>

Where "erotic" is the term to which you wish to give a "negative boost". To add another term, add another bq=....

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