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 Andreas Lønes <an...@dips.no> on 2019/02/13 10:49:01 UTC

Terms Query Parser: filtering on null and strings with whitespace.

I am experiencing some weird behaviour when using terms query parser where I am filtering on documents that has no value for a given field(null) and strings with whitespaces.

I can filter on documents not having a value OR having some specific values for the field as long as the value does not have a whitespace(example 1). I can also filter on specific values with whitespace)(example 2).
What I am not able to make work is to filter on documents not having a value OR certain terms with whitespace(example 3)

These work:
    1. (*:* AND -department_shortname:[* TO *]) OR {!tag=department_shortname terms f=department_shortname}BARN,KIR
    2. {!tag=department_name terms f=department_name}Kirurgisk avdeling
Does not work:
    3. (*:* AND -department_name:[* TO *]) OR {!tag=department_name terms f=department_name}Kirurgisk avdeling

The configuration of the fields if that is of any value:
    <field name="department_name" type="string" indexed="true" stored="true" required="false" multiValued="false" />
    <field name="department_shortname" type="string" indexed="true" stored="true" required="false" multiValued="false" />

So far, the only solution I can come up with is to index some kind of value that represents null, but as of my understanding it is recommended that null is not indexed.


Thanks,
Andreas

Re: Terms Query Parser: filtering on null and strings with whitespace.

Posted by Mikhail Khludnev <mk...@apache.org>.
Oh yeah, my pet peeve. This is the cure.
(*:* AND -department_name:[* TO *]) OR {!tag=department_name terms
f=department_name v='Kirurgisk avdeling'}
no comments.

On Wed, Feb 13, 2019 at 1:49 PM Andreas Lønes <an...@dips.no> wrote:

> I am experiencing some weird behaviour when using terms query parser where
> I am filtering on documents that has no value for a given field(null) and
> strings with whitespaces.
>
> I can filter on documents not having a value OR having some specific
> values for the field as long as the value does not have a
> whitespace(example 1). I can also filter on specific values with
> whitespace)(example 2).
> What I am not able to make work is to filter on documents not having a
> value OR certain terms with whitespace(example 3)
>
> These work:
>     1. (*:* AND -department_shortname:[* TO *]) OR
> {!tag=department_shortname terms f=department_shortname}BARN,KIR
>     2. {!tag=department_name terms f=department_name}Kirurgisk avdeling
> Does not work:
>     3. (*:* AND -department_name:[* TO *]) OR {!tag=department_name terms
> f=department_name}Kirurgisk avdeling
>
> The configuration of the fields if that is of any value:
>     <field name="department_name" type="string" indexed="true"
> stored="true" required="false" multiValued="false" />
>     <field name="department_shortname" type="string" indexed="true"
> stored="true" required="false" multiValued="false" />
>
> So far, the only solution I can come up with is to index some kind of
> value that represents null, but as of my understanding it is recommended
> that null is not indexed.
>
>
> Thanks,
> Andreas
>


-- 
Sincerely yours
Mikhail Khludnev