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 Anil <an...@gmail.com> on 2016/07/04 07:05:43 UTC
Index and query brackets
HI,
how can index and query content with brackets as bracket is used for range
query
Ex : [DATA]
-
Anil
Re: Index and query brackets
Posted by Anil <an...@gmail.com>.
Thanks Chris for the response.
I am using TextField and edismax query parser.
i have changed filters so that brackets are not trimmed. i will test it and
let the group know if that is working.
Thanks.
On 19 July 2016 at 03:27, Chris Hostetter <ho...@fucit.org> wrote:
>
>
> If you index the literal string value of "[ DATA ]" and then you wnat to
> be able to query for "[ DATA ]" again later there are two things you have
> to consider:
>
> 1) how is your field value analyzed?
>
> If you use something like StrField then an index term for the literal
> string "[ DATA ]" is created and put in your index, but if you use
> TextField then the analyzer configured might do things like tokenize the
> string into 3 distinct terms, lowercase alpha charagers, or perhaps even
> drop the bracket characters completely -- as long as that is consistent at
> index time and query time then you should be fine, as long as you pay
> attention to...
>
> 2) what query parser are you using.
>
> The default parser treats brackets and whitespace as special meta-syntax
> characters. You can quote them, or backslah escape them but the
> whitespace itself may also need to be quoted/escaped to prevent the parser
> from trying to make a boolena query for 3 terms ("[", "DATA", "]") instead
> of 1.
>
> alternatively you can use things like the "field" QParser, which let's you
> target a specific field by name, with a query string value that can be
> anything -- there are no special meta-syntax characters for hte field
> parser. and the appopriate analyer wll be used to create a TermQuery or
> PhraseQuery (as needed)
>
> ie: q = {!field f=your_field_name}[ DATA ]
>
>
> https://cwiki.apache.org/confluence/display/solr/Other+Parsers
>
>
> : Date: Tue, 5 Jul 2016 08:45:57 +0530
> : From: Anil <an...@gmail.com>
> : Reply-To: solr-user@lucene.apache.org
> : To: solr-user@lucene.apache.org
> : Subject: Re: Index and query brackets
> :
> : NO Ediwin. Thanks for your response.
> :
> : i was checking how to check [1 TO 5] as a content not as a range query.
> :
> : i tried by escaping [ and ] and did not work. seems need to check
> analyzers
> : at index side.
> :
> : Regards,
> : Anil
> :
> : On 5 July 2016 at 08:42, Zheng Lin Edwin Yeo <ed...@gmail.com>
> wrote:
> :
> : > Hi Anil,
> : >
> : > Are you referring to something like q=level:[1 TO 5] ? This will
> search for
> : > level that ranges from 1 to 5.
> : > You may refer to the documentation here:
> : > https://wiki.apache.org/solr/SolrQuerySyntax
> : >
> : > Regards,
> : > Edwin
> : >
> : >
> : > On 4 July 2016 at 15:05, Anil <an...@gmail.com> wrote:
> : >
> : > > HI,
> : > >
> : > > how can index and query content with brackets as bracket is used for
> : > range
> : > > query
> : > >
> : > > Ex : [DATA]
> : > >
> : > > -
> : > > Anil
> : > >
> : >
> :
>
> -Hoss
> http://www.lucidworks.com/
>
Re: Index and query brackets
Posted by Chris Hostetter <ho...@fucit.org>.
If you index the literal string value of "[ DATA ]" and then you wnat to
be able to query for "[ DATA ]" again later there are two things you have
to consider:
1) how is your field value analyzed?
If you use something like StrField then an index term for the literal
string "[ DATA ]" is created and put in your index, but if you use
TextField then the analyzer configured might do things like tokenize the
string into 3 distinct terms, lowercase alpha charagers, or perhaps even
drop the bracket characters completely -- as long as that is consistent at
index time and query time then you should be fine, as long as you pay
attention to...
2) what query parser are you using.
The default parser treats brackets and whitespace as special meta-syntax
characters. You can quote them, or backslah escape them but the
whitespace itself may also need to be quoted/escaped to prevent the parser
from trying to make a boolena query for 3 terms ("[", "DATA", "]") instead
of 1.
alternatively you can use things like the "field" QParser, which let's you
target a specific field by name, with a query string value that can be
anything -- there are no special meta-syntax characters for hte field
parser. and the appopriate analyer wll be used to create a TermQuery or
PhraseQuery (as needed)
ie: q = {!field f=your_field_name}[ DATA ]
https://cwiki.apache.org/confluence/display/solr/Other+Parsers
: Date: Tue, 5 Jul 2016 08:45:57 +0530
: From: Anil <an...@gmail.com>
: Reply-To: solr-user@lucene.apache.org
: To: solr-user@lucene.apache.org
: Subject: Re: Index and query brackets
:
: NO Ediwin. Thanks for your response.
:
: i was checking how to check [1 TO 5] as a content not as a range query.
:
: i tried by escaping [ and ] and did not work. seems need to check analyzers
: at index side.
:
: Regards,
: Anil
:
: On 5 July 2016 at 08:42, Zheng Lin Edwin Yeo <ed...@gmail.com> wrote:
:
: > Hi Anil,
: >
: > Are you referring to something like q=level:[1 TO 5] ? This will search for
: > level that ranges from 1 to 5.
: > You may refer to the documentation here:
: > https://wiki.apache.org/solr/SolrQuerySyntax
: >
: > Regards,
: > Edwin
: >
: >
: > On 4 July 2016 at 15:05, Anil <an...@gmail.com> wrote:
: >
: > > HI,
: > >
: > > how can index and query content with brackets as bracket is used for
: > range
: > > query
: > >
: > > Ex : [DATA]
: > >
: > > -
: > > Anil
: > >
: >
:
-Hoss
http://www.lucidworks.com/
Re: Index and query brackets
Posted by Anil <an...@gmail.com>.
NO Ediwin. Thanks for your response.
i was checking how to check [1 TO 5] as a content not as a range query.
i tried by escaping [ and ] and did not work. seems need to check analyzers
at index side.
Regards,
Anil
On 5 July 2016 at 08:42, Zheng Lin Edwin Yeo <ed...@gmail.com> wrote:
> Hi Anil,
>
> Are you referring to something like q=level:[1 TO 5] ? This will search for
> level that ranges from 1 to 5.
> You may refer to the documentation here:
> https://wiki.apache.org/solr/SolrQuerySyntax
>
> Regards,
> Edwin
>
>
> On 4 July 2016 at 15:05, Anil <an...@gmail.com> wrote:
>
> > HI,
> >
> > how can index and query content with brackets as bracket is used for
> range
> > query
> >
> > Ex : [DATA]
> >
> > -
> > Anil
> >
>
Re: Index and query brackets
Posted by Zheng Lin Edwin Yeo <ed...@gmail.com>.
Hi Anil,
Are you referring to something like q=level:[1 TO 5] ? This will search for
level that ranges from 1 to 5.
You may refer to the documentation here:
https://wiki.apache.org/solr/SolrQuerySyntax
Regards,
Edwin
On 4 July 2016 at 15:05, Anil <an...@gmail.com> wrote:
> HI,
>
> how can index and query content with brackets as bracket is used for range
> query
>
> Ex : [DATA]
>
> -
> Anil
>