Solr Query Language

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Solr Query Language

Jack L

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

Reply | Threaded
Open this post in threaded view
|

Re: Solr Query Language

Bertrand Delacretaz
On 4/16/07, Jack L <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

RE: Solr Query Language

Daniel Pitts-4
In reply to this post by Jack L
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:[hidden email]]
> Sent: Sunday, April 15, 2007 10:32 PM
> To: [hidden email]
> 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
>
Reply | Threaded
Open this post in threaded view
|

strange results from lucene

Bill Tantzen-3
In reply to this post by Jack L
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

Reply | Threaded
Open this post in threaded view
|

Re: strange results from lucene

Bertrand Delacretaz
On 4/17/07, Bill Tantzen <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: strange results from lucene

Daniel Naber-10
In reply to this post by Bill Tantzen-3
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
Reply | Threaded
Open this post in threaded view
|

RE: strange results from lucene

Bill Tantzen-3
In reply to this post by Bertrand Delacretaz
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: [hidden email] [mailto:[hidden email]] On
> Behalf Of Bertrand Delacretaz
> Sent: Tuesday, April 17, 2007 3:00 PM
> To: [hidden email]
> Subject: Re: strange results from lucene
>
> On 4/17/07, Bill Tantzen <[hidden email]> 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
>