Actually before our query was -msg_content1:(ASI-STD-ITB*) OR -(status_id:1020 
AND project_id:2143947). Now we want to add AND recordRetentionPolicyStatus:0 
So we have added brackets in first query like (-msg_content1:(ASI-STD-ITB*) OR 
-(status_id:1020 AND project_id:2143947)) and append the AND 
recordRetentionPolicyStatus:0 after that string.

If I used brackets and not append the AND recordRetentionPolicyStatus:0 then it 
should properly parsed query but when I add that part it will not parsed 
properly.

Query in debug mode
Working properly
<str name="querystring">(-msg_content1:(ASI-STD-ITB*) OR -(status_id:1020 AND 
project_id:2143947))</str>
<str name="parsedquery">-msg_content1:asi-std-itb* -(+status_id:1020 
+project_id:2143947)</str>
Not working properly
<str name="querystring">(-msg_content1:(ASI-STD-ITB*) OR -(status_id:1020 AND 
project_id:2143947)) AND recordRetentionPolicyStatus:0</str>
<str name="parsedquery">+(-msg_content1:asi-std-itb* -(+status_id:1020 
+project_id:2143947)) +recordRetentionPolicyStatus:0</str>

Why + sign add?

Regards,
Vishal

From: Alessandro Benedetti<mailto:a.benede...@sease.io>
Sent: 10 July 2023 14:08
To: users@solr.apache.org<mailto:users@solr.apache.org>
Subject: Re: Negative Query not working when use brackets in Solr 8.9.0

I see plenty of questionable practices here that can be improved:
1) wildcard queries -> unless really necessary, you should avoid them as
much as possible and design a proper text analysis chain (indexing and
query time) instead
2) negative queries -> they are tricky, some query parsers manage pure
negative queries, when you subtract something from something it should be
fine but  I recommend to debug the parsed query and check if it satisfy
your requirements
3) your definition of records coming or not coming is too vague, you should
spend more time analyzing the results and understanding if the the proper
records are coming or not (if you don't know, who can? :))

Cheers
--------------------------
*Alessandro Benedetti*
Director @ Sease Ltd.
*Apache Lucene/Solr Committer*
*Apache Solr PMC Member*

e-mail: a.benede...@sease.io


*Sease* - Information Retrieval Applied
Consulting | Training | Open Source

Website: Sease.io <http://sease.io/>
LinkedIn <https://linkedin.com/company/sease-ltd> | Twitter
<https://twitter.com/seaseltd> | Youtube
<https://www.youtube.com/channel/UCDx86ZKLYNpI3gzMercM7BQ> | Github
<https://github.com/seaseltd>

[image: Mailtrack]
<https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality11&;>
Sender
notified by
Mailtrack
<https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality11&;>
10/07/23,
10:31:38

On Mon, 10 Jul 2023 at 09:58, Vishal Patel <vishalpatel199...@outlook.com>
wrote:

>
>
> We are using Solr 8.9.0. We have configured Solr cloud like 2 shards and
> each shard has one replica. We have used 5 zoo keepers for Solr cloud.
>
> When we hit the query q= *(-msg_content1:(ASI-STD-ITB*) OR
> -(status_id:1020 AND project_id:2143947)) AND recordRetentionPolicyStatus:0*
> in Solr admin panel for one collection, we do not get the records but when
> we hit the query q= *(-msg_content1:(ASI-STD-ITB*) OR -(status_id:1020
> AND project_id:2143947)) * and fq= *recordRetentionPolicyStatus:0 *in
> Solr admin panel for one collection, we get the records. If we remove
> brackets like q= *-msg_content1:(ASI-STD-ITB*) OR -(status_id:1020 AND
> project_id:2143947) AND recordRetentionPolicyStatus:0 *then records are
> coming but not sure it is proper records come or not.
>
>
>
> Can you please help me what is issue here? Why is it not working if we add
> bracket?
>
>
>
> Regards,
>
> Vishal
>
>
>

Reply via email to