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 alexpusch <al...@getjaco.com> on 2019/05/05 15:07:14 UTC
Custom post filter with support for 'OR' queries
Hi,
I'm trying to write my own custom post filter. I'm following the following
guide -
http://qaware.blogspot.com/2014/11/how-to-write-postfilter-for-solr-49.html
My implementation works for a simple query:
{!myFilter}query
But I need to perform OR queries in addition to my post filter:
field:value OR {!myFilter}query
I'm getting the follow error:
java.lang.UnsupportedOperationException: Query {!cache=false cost=100} does
not implement createWeight
As I only want this queryParser to only run on results on a post filter
manner, I presume I do not need or can implement createWeight.
Can a post filter be applied like this? Or should I look for a different
approach?
--
Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html
Re: Custom post filter with support for 'OR' queries
Posted by Mikhail Khludnev <mk...@apache.org>.
This case isn't worth to bother with custom code. Deriving terms in
analysis usually works fine.
This might be addressed with
https://lucene.apache.org/solr/guide/6_6/filter-descriptions.html#reversed-wildcard-filter
or
https://lucene.apache.org/solr/guide/6_6/tokenizers.html#Tokenizers-PathHierarchyTokenizer.
I haven't thought deep enough, but believe it might be tinkered by standard
analysis toolbox.
On Sun, May 5, 2019 at 10:28 PM alexpusch <al...@getjaco.com> wrote:
> Thanks for the quick reply.
>
> The real data is an representation of an HTML element "body div.class1
> div.b.a", My goal is to match documents by css selector i.e ".class1 .a.b"
>
> The field I'm querying on is a tokenzied texts field. The post filter takes
> the doc value of the field (which is not tokenized - whole string),
> transforms it a bit, and matches it to some input regex.
>
> My alternative is to create a non tokenzied copy field, create a custom
> filter that makes the transformation on index time and use regular regex
> query on it. Writing the post filter was my first choice since I wanted to
> avoid copying data and I'm not sure about regular regex query performance.
> The collection I'm querying is quite huge.
>
>
>
>
>
> --
> Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html
>
--
Sincerely yours
Mikhail Khludnev
Re: Custom post filter with support for 'OR' queries
Posted by alexpusch <al...@getjaco.com>.
Thanks for the quick reply.
The real data is an representation of an HTML element "body div.class1
div.b.a", My goal is to match documents by css selector i.e ".class1 .a.b"
The field I'm querying on is a tokenzied texts field. The post filter takes
the doc value of the field (which is not tokenized - whole string),
transforms it a bit, and matches it to some input regex.
My alternative is to create a non tokenzied copy field, create a custom
filter that makes the transformation on index time and use regular regex
query on it. Writing the post filter was my first choice since I wanted to
avoid copying data and I'm not sure about regular regex query performance.
The collection I'm querying is quite huge.
--
Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html
Re: Custom post filter with support for 'OR' queries
Posted by Erik Hatcher <er...@gmail.com>.
Can you detail you actual querying need here? You’re down into some trenches with PostFilter, which is designed purely as an AND-like filtering mechanism, and contrary to ORing with it, generally speaking.
Let’s see the real data and need to see what’s the best way to tackle it.
Also, with nesting qparsers, the curly brackets need to fully enclose the query, not leaving the expression to outside the brackets ambiguously. Use {!myparser v=$my_q} where &my_q=the expression.
Erik
> On May 5, 2019, at 11:07, alexpusch <al...@getjaco.com> wrote:
>
> Hi,
>
> I'm trying to write my own custom post filter. I'm following the following
> guide -
> http://qaware.blogspot.com/2014/11/how-to-write-postfilter-for-solr-49.html
>
> My implementation works for a simple query:
> {!myFilter}query
>
> But I need to perform OR queries in addition to my post filter:
> field:value OR {!myFilter}query
>
> I'm getting the follow error:
> java.lang.UnsupportedOperationException: Query {!cache=false cost=100} does
> not implement createWeight
>
> As I only want this queryParser to only run on results on a post filter
> manner, I presume I do not need or can implement createWeight.
>
> Can a post filter be applied like this? Or should I look for a different
> approach?
>
>
>
> --
> Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html