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/11 05:20:57 UTC

fq doesn't return any results

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: 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