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 Jack L <jl...@yahoo.ca> on 2007/04/16 07:31:40 UTC
Solr Query Language
Is the lucene query syntax available in solr? I saw this page
about lucene query syntax:
http://lucene.apache.org/java/docs/queryparsersyntax.html
I tried "width:[0 TO 500]" and got an exception:
java.lang.NumberFormatException: For input string: "TO500"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:447)
at java.lang.Integer.parseInt(Integer.java:497)
If solr query language is different from that of Lucene, is
there a page that documents this?
--
Best regards,
Jack
Re: strange results from lucene
Posted by Daniel Naber <lu...@danielnaber.de>.
On Tuesday 17 April 2007 21:51, Bill Tantzen wrote:
> However, when I search with 'q=ethics' in solr, I get almost 10,000
> matches. With my client, I get 0.
If you don't specify a field, your client will use this code:
Query query = new TermQuery( new Term("", "ethics") );
This is legal, but you will get no hits, as there's not field "". Also see
the Lucene FAQ at
http://wiki.apache.org/lucene-java/LuceneFAQ#head-3558e5121806fb4fce80fc022d889484a9248b71
Regards
Daniel
--
http://www.danielnaber.de
RE: strange results from lucene
Posted by Bill Tantzen <ta...@tc.umn.edu>.
Thanks to all that responded! This did the trick. I used
admin/analysis.jsp to determine how solr indexed my data and how solr parses
my query. I used a QueryParser and applied the same filters to my query,
and now my results match exactly.
Thanks again!
> -----Original Message-----
> From: bdelacretaz@gmail.com [mailto:bdelacretaz@gmail.com] On
> Behalf Of Bertrand Delacretaz
> Sent: Tuesday, April 17, 2007 3:00 PM
> To: solr-user@lucene.apache.org
> Subject: Re: strange results from lucene
>
> On 4/17/07, Bill Tantzen <ta...@tc.umn.edu> wrote:
>
> > ...However, when I search with 'q=ethics' in solr, I get
> almost 10,000 matches.
> > With my client, I get 0....
>
> What kind of analyzer do you use when indexing that field? If
> you have a stemmer, for example, "ethics" might be indexed
> without the ending "s".
>
> The best way to debug such problems is with the analyzer admin tool:
> http://localhost:8983/solr/admin/analysis.jsp - that page
> will show you how your field is processed while indexing.
>
> HTH,
> -Bertrand
>
Re: strange results from lucene
Posted by Bertrand Delacretaz <bd...@apache.org>.
On 4/17/07, Bill Tantzen <ta...@tc.umn.edu> wrote:
> ...However, when I search with 'q=ethics' in solr, I get almost 10,000 matches.
> With my client, I get 0....
What kind of analyzer do you use when indexing that field? If you have
a stemmer, for example, "ethics" might be indexed without the ending
"s".
The best way to debug such problems is with the analyzer admin tool:
http://localhost:8983/solr/admin/analysis.jsp - that page will show
you how your field is processed while indexing.
HTH,
-Bertrand
strange results from lucene
Posted by Bill Tantzen <ta...@tc.umn.edu>.
Hi all!
I have a simple java search client with which I am querying the index
created by solr. Most of the time, I am seeing consistent results - in
other words, when my query is 'title:dog' with my client, I get 46 matching
documents, and when I have a 'q=title:dog' in the solr url, I also get 46
matching documents as I would expect.
However, when I search with 'q=ethics' in solr, I get almost 10,000 matches.
With my client, I get 0. What is going on here? Is the clue here that the
word 'ethics' appears with relatively high frequency?
The simple client I refer to looks like so:
public class SolrSearch {
private static String indexDir =
"/usr/local/apache-tomcat-5.5.20/conf/solr/data/index";
// ================================================================
public static void main( String[] args ) throws IOException {
IndexSearcher searcher = new IndexSearcher( indexDir );
Query query = new TermQuery( new Term( args[0], args[1] ) );
System.out.println ( "query: " + query.toString() );
Hits hits = searcher.search( query );
System.out.println( "search for " + args[1] + " within " + args[0]
);
System.out.println( hits.length() + " matching entries" );
}
If anyone can help me see the error of my ways, I will appreciate it!
Cheers,
Bill
Re: Solr Query Language
Posted by Bertrand Delacretaz <bd...@apache.org>.
On 4/16/07, Jack L <jl...@yahoo.ca> wrote:
>
> Is the lucene query syntax available in solr? ...
The syntax depends on the request handler used, if you're using the
standard one the docs are at
http://wiki.apache.org/solr/StandardRequestHandler
-Bertrand
RE: Solr Query Language
Posted by Daniel Pitts <Da...@cnet.com>.
It looks like (from the exception) that you missed a space.
Perhaps your actual query was constructed like:
String query = "width:[" + lowWidth + " TO" + highWidth +"]";
Where you *wanted*
String query = "width:[" + lowWidth + " TO " + highWidth +"]";
> -----Original Message-----
> From: Jack L [mailto:jlist9@yahoo.ca]
> Sent: Sunday, April 15, 2007 10:32 PM
> To: solr-user@lucene.apache.org
> Subject: Solr Query Language
>
>
> Is the lucene query syntax available in solr? I saw this page
> about lucene query syntax:
> http://lucene.apache.org/java/docs/queryparsersyntax.html
>
> I tried "width:[0 TO 500]" and got an exception:
> java.lang.NumberFormatException: For input string: "TO500"
> at
> java.lang.NumberFormatException.forInputString(NumberFormatExc
> eption.java:48)
> at java.lang.Integer.parseInt(Integer.java:447)
> at java.lang.Integer.parseInt(Integer.java:497)
>
> If solr query language is different from that of Lucene, is
> there a page that documents this?
>
> --
> Best regards,
> Jack
>