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 ZHANG Liang F <Li...@alcatel-sbell.com.cn> on 2012/04/09 08:10:29 UTC

Problem about range search

Hi,
I ran into a problem when trying range facet search. I had a schema define like this:
 <fields>
   <field name="title" type="string" indexed="true" stored="true"/>
   <field name="author" type="string" indexed="true" stored="true" />
   <field name="text" type="text" indexed="true" stored="true" />
   <field name="path" type="string" indexed="true" stored="true" />
   <field name="size" type="long" indexed="true" stored="true" />
   <field name="lastmodified" type="date" indexed="true" stored="true" />
 </fields>

I try to set up a range search on "size" field which stands for the size of a file. So I have the following requestHandler config in solrconfig.xml:
  <str name="facet.range.other">after</str>
  <str name="facet.range">size</str>
  <int name="f.size.facet.range.start">0</int>
  <int name="f.size.facet.range.end">15728640</int><!-- around 15M -->
  <int name="f.size.facet.range.gap">3145728</int><!-- around 3M -->

But an error says:  Unable to range facet on field:size{type=long,properties=indexed,stored,omitNorms,omitTermFreqAndPositions}

It doesn't show any clue, and I also tried <long> tag, but got the same error.

Could you please help to suggest?

Thanks in advance!

RE: fq doesn't return any results

Posted by ZHANG Liang F <Li...@alcatel-sbell.com.cn>.
Thanks a lot! You did save me a lot of time! All the solutions you provided are working perfectly fine!


-----Original Message-----
From: Chris Hostetter [mailto:hossman_lucene@fucit.org] 
Sent: 2012年4月11日 11:41
To: solr-user@lucene.apache.org
Subject: Re: fq doesn't return any results


: 1. &fq=path%3AE%3A%5Cmy_project%5Cecmkit%5Cinfotouch
: (org.apache.lucene.queryParser.ParseException: Cannot parse
: 'path:E:\my_project\ecmkit\infotouch': Encountered " ":" ": "" )
: 
: 2. &fq=path:"E:\my_project\ecmkit\test"  (return 0 result)

the problem in the first example is that evne though you have URL encoded the query string, you haven't done anything to escape the metacharaters that are special to the query parser.

In your second example, you've put quotes arround the value, which helps with some things -- but even in quotes you have to backslash escape the backslash itself...

  fq=path:"E:\\my_project\\ecmkit\\test"

a far easier way to do what you are trying to do would be to use either the FieldQParserPlutin or the TermQParserPlugin...

fq={!field f=path}E:\my_project\ecmkit\test fq={!term f=path}E:\my_project\ecmkit\test

...no special escaping or quoting required


-Hoss

Re: fq doesn't return any results

Posted by Chris Hostetter <ho...@fucit.org>.
: 1. &fq=path%3AE%3A%5Cmy_project%5Cecmkit%5Cinfotouch 
: (org.apache.lucene.queryParser.ParseException: Cannot parse 
: 'path:E:\my_project\ecmkit\infotouch': Encountered " ":" ": "" )
: 
: 2. &fq=path:"E:\my_project\ecmkit\test"  (return 0 result)

the problem in the first example is that evne though you have URL encoded 
the query string, you haven't done anything to escape the metacharaters 
that are special to the query parser.

In your second example, you've put quotes arround the value, which helps 
with some things -- but even in quotes you have to backslash escape the 
backslash itself...

  fq=path:"E:\\my_project\\ecmkit\\test"

a far easier way to do what you are trying to do would be to use either 
the FieldQParserPlutin or the TermQParserPlugin...

fq={!field f=path}E:\my_project\ecmkit\test
fq={!term f=path}E:\my_project\ecmkit\test

...no special escaping or quoting required


-Hoss

fq doesn't return any results

Posted by ZHANG Liang F <Li...@alcatel-sbell.com.cn>.
Hi, 
I had field defined to store the location of a file:
<field name="path" type="string" indexed="true" stored="true" />

And the return value is something like:
<result name="response" numFound="25" start="0">
  <doc>
      <str name="path">E:\my_project\ecmkit\test</str> 
      ...

But when I try to filter the result by using fq, None of the following return any results:

1. &fq=path%3AE%3A%5Cmy_project%5Cecmkit%5Cinfotouch (org.apache.lucene.queryParser.ParseException: Cannot parse 'path:E:\my_project\ecmkit\infotouch': Encountered " ":" ": "" )

2. &fq=path:"E:\my_project\ecmkit\test"  (return 0 result)

Please help to suggest.

Thanks in advance. 

RE: Problem about range search

Posted by ZHANG Liang F <Li...@alcatel-sbell.com.cn>.
Hi, 
I just found the root cause. The definition for the 'long' type is not right. the previous definition was:

<fieldType name="long" class="solr.LongField" omitNorms="true"/>

which doesn't support range query! now I changed to : <fieldType name="long" class="solr.TrieLongField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>, and it's done!

Thanks a lot!
Liang

-----Original Message-----
From: Erick Erickson [mailto:erickerickson@gmail.com] 
Sent: 2012年4月10日 6:53
To: solr-user@lucene.apache.org
Subject: Re: Problem about range search

Hmmm, works fine for me using the "popularity" field in the default schema.

What version of Solr are you using? What is your complete handler definition?

Best
Erick

On Mon, Apr 9, 2012 at 12:10 AM, ZHANG Liang F <Li...@alcatel-sbell.com.cn> wrote:
> Hi,
> I ran into a problem when trying range facet search. I had a schema define like this:
>  <fields>
>   <field name="title" type="string" indexed="true" stored="true"/>
>   <field name="author" type="string" indexed="true" stored="true" />
>   <field name="text" type="text" indexed="true" stored="true" />
>   <field name="path" type="string" indexed="true" stored="true" />
>   <field name="size" type="long" indexed="true" stored="true" />
>   <field name="lastmodified" type="date" indexed="true" stored="true" 
> />
>  </fields>
>
> I try to set up a range search on "size" field which stands for the size of a file. So I have the following requestHandler config in solrconfig.xml:
>  <str name="facet.range.other">after</str>
>  <str name="facet.range">size</str>
>  <int name="f.size.facet.range.start">0</int>
>  <int name="f.size.facet.range.end">15728640</int><!-- around 15M -->
>  <int name="f.size.facet.range.gap">3145728</int><!-- around 3M -->
>
> But an error says:  Unable to range facet on 
> field:size{type=long,properties=indexed,stored,omitNorms,omitTermFreqA
> ndPositions}
>
> It doesn't show any clue, and I also tried <long> tag, but got the same error.
>
> Could you please help to suggest?
>
> Thanks in advance!

Re: Problem about range search

Posted by Erick Erickson <er...@gmail.com>.
Hmmm, works fine for me using the "popularity" field in
the default schema.

What version of Solr are you using? What is your complete
handler definition?

Best
Erick

On Mon, Apr 9, 2012 at 12:10 AM, ZHANG Liang F
<Li...@alcatel-sbell.com.cn> wrote:
> Hi,
> I ran into a problem when trying range facet search. I had a schema define like this:
>  <fields>
>   <field name="title" type="string" indexed="true" stored="true"/>
>   <field name="author" type="string" indexed="true" stored="true" />
>   <field name="text" type="text" indexed="true" stored="true" />
>   <field name="path" type="string" indexed="true" stored="true" />
>   <field name="size" type="long" indexed="true" stored="true" />
>   <field name="lastmodified" type="date" indexed="true" stored="true" />
>  </fields>
>
> I try to set up a range search on "size" field which stands for the size of a file. So I have the following requestHandler config in solrconfig.xml:
>  <str name="facet.range.other">after</str>
>  <str name="facet.range">size</str>
>  <int name="f.size.facet.range.start">0</int>
>  <int name="f.size.facet.range.end">15728640</int><!-- around 15M -->
>  <int name="f.size.facet.range.gap">3145728</int><!-- around 3M -->
>
> But an error says:  Unable to range facet on field:size{type=long,properties=indexed,stored,omitNorms,omitTermFreqAndPositions}
>
> It doesn't show any clue, and I also tried <long> tag, but got the same error.
>
> Could you please help to suggest?
>
> Thanks in advance!