You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Stavros Macrakis <ma...@alum.mit.edu> on 2020/07/07 01:11:49 UTC
Search for term except within phrase
(Sorry for sending this with the wrong subject earlier.)
How can I search for a term except when it's part of certain phrases?
For example, I might want to find documents mentioning "pepper" where it is
not part of the phrases "chili pepper", "hot pepper", or "pepper sauce".
It does not work to search for [pepper NOT ("chili pepper" OR "hot pepper"
OR "pepper sauce")] because that excludes all documents which mention
"chili pepper" even if they also mention "black pepper" or the unmodified
word "pepper". Maybe some way using synonyms?
Thanks!
-s
Re: Search for term except within phrase
Posted by Emir Arnautović <em...@sematext.com>.
Hi Stavros,
I didn’t check what’s supported in ComplexPhraseQueryParser but that is wrapper around span queries, so you should be able to do what you need: https://lucene.apache.org/solr/guide/7_6/other-parsers.html#complex-phrase-query-parser <https://lucene.apache.org/solr/guide/7_6/other-parsers.html#complex-phrase-query-parser>
HTH,
Emir
--
Monitoring - Log Management - Alerting - Anomaly Detection
Solr & Elasticsearch Consulting Support Training - http://sematext.com/
> On 7 Jul 2020, at 03:11, Stavros Macrakis <ma...@alum.mit.edu> wrote:
>
> (Sorry for sending this with the wrong subject earlier.)
>
> How can I search for a term except when it's part of certain phrases?
>
> For example, I might want to find documents mentioning "pepper" where it is
> not part of the phrases "chili pepper", "hot pepper", or "pepper sauce".
>
> It does not work to search for [pepper NOT ("chili pepper" OR "hot pepper"
> OR "pepper sauce")] because that excludes all documents which mention
> "chili pepper" even if they also mention "black pepper" or the unmodified
> word "pepper". Maybe some way using synonyms?
>
> Thanks!
>
> -s