Delete by query using SolrNotQuery doesn't seem to work

400 views
Skip to first unread message

Ken Foster

unread,
Jan 30, 2013, 4:35:17 PM1/30/13
to sol...@googlegroups.com
I'm trying to delete all records where a field called 'type' is *not* some value. If I build a query
   ISolrQueryResults<SolrContent> rslt = solrInstance.Query(new SolrNotQuery(new SolrQueryByField("type", "abc")));
I get back all records where 'type' is not 'abc', just as I expect.

However when I do a delete by query,
   ResponseHeader rh = solrd.Delete(new SolrNotQuery(new SolrQueryByField("type", "abc")));
it doesn't delete anything. 

I also tried Delete(new SolrQuery("-type:abc"));  and that didn't work either. 

Am I missing a step?
Thanks,
Ken

[mRg]

unread,
Jan 30, 2013, 4:41:21 PM1/30/13
to sol...@googlegroups.com
Hi Ken

Seems like it might be a raw Solr issue .. https://issues.apache.org/jira/browse/SOLR-381

They suggest a workaround of adding *:* .. so you could try Delete(SolrQuery.All + new SolrNotQuery(new SolrQueryByField("type", "abc"))) .. or a variation so that you get 
"*:* -type:abc" as your query.

Give that a try, interested to hear if it's that ! Odd you can't do a pure negative query in delete !

Stephen


--
You received this message because you are subscribed to the Google Groups "SolrNet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to solrnet+u...@googlegroups.com.
To post to this group, send email to sol...@googlegroups.com.
Visit this group at http://groups.google.com/group/solrnet?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ken Foster

unread,
Jan 30, 2013, 4:55:24 PM1/30/13
to sol...@googlegroups.com
That worked, thanks. Well, except the + operator in the query, that didn't work with the version I have, but I just created a SolrMultipleCriteriaQuery and it worked fine.

Thanks again.
Reply all
Reply to author
Forward
0 new messages