You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by sunil goyal <su...@gmail.com> on 2005/01/28 12:40:55 UTC

lucene query (sql kind)

Hello all,

I want to run dynamic queries against the lucene index. Is there any
native syntax available for Lucene so that I can query, by first
generating the query in say an XML or SQL like format (cache this
query) and then  use this query over lucene index.


e.g. So a lucene query syntax in which I can define a query
(name="john" AND age <10)  and then I can just use this query to
execute over Lucene index.


Regards
Sunil

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Re: lucene query (sql kind)

Posted by sunil goyal <su...@gmail.com>.
Hello,

Thanks, It works fine.

> The field parameter simply defines the default field for all queries
> without an explicit field specification (<field>:).
> Using 'field AND field' as default field does not make sense but does
> not hurt as long as the default field is not used.
> I'm not sure why you choose that.
I just thought that Query Parser needs to be specifies what it should
expect before hand. So did "field AND field". But I was wrong.

> Further name:\"john\" and name:john should be the same.
Just in case it's not "john" but "hello john" or some phrase.

Regards
Sunil



On Fri, 28 Jan 2005 13:26:26 +0100, Morus Walter <mo...@tanto.de> wrote:
> sunil goyal writes:
> >
> > I was just trying that...
> >
> > QueryParser qp = new QueryParser("field AND field", new StandardAnalyzer());
> > Query query = qp.parse("name:\"john\" AND age:[10 TO 16]");
> >
> > It works fine with this. Do I need to specify that QueryParser should
> > expect things in order
> > "field AND field". Or can I do without it?
> > 
> The field parameter simply defines the default field for all queries
> without an explicit field specification (<field>:).
> Using 'field AND field' as default field does not make sense but does
> not hurt as long as the default field is not used.
> I'm not sure why you choose that.
> 
> Further name:\"john\" and name:john should be the same.
> 
> HTH
>   Morus
>

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Re: lucene query (sql kind)

Posted by Morus Walter <mo...@tanto.de>.
sunil goyal writes:
> 
> I was just trying that...
> 
> QueryParser qp = new QueryParser("field AND field", new StandardAnalyzer());
> Query query = qp.parse("name:\"john\" AND age:[10 TO 16]");
> 
> It works fine with this. Do I need to specify that QueryParser should
> expect things in order
> "field AND field". Or can I do without it?
> 
The field parameter simply defines the default field for all queries 
without an explicit field specification (<field>:).
Using 'field AND field' as default field does not make sense but does
not hurt as long as the default field is not used.
I'm not sure why you choose that.

Further name:\"john\" and name:john should be the same.

HTH
  Morus

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Re: lucene query (sql kind)

Posted by David Escuer <da...@simpple.com>.
I've merged some different fields in one query, with the name of one of 
these fields as the second parameter in the
static method, and it worked fine.
Also, you can do a little query parser, and build the queries with 
BooleanQuery.....

David


sunil goyal wrote:

>Hello,
>
>I was just trying that...
>
>QueryParser qp = new QueryParser("field AND field", new StandardAnalyzer());
>Query query = qp.parse("name:\"john\" AND age:[10 TO 16]");
>
>It works fine with this. Do I need to specify that QueryParser should
>expect things in order
>"field AND field". Or can I do without it?
>
>The static method of QueryParser.parse(String , String, Analyzer) -
>expects the first string to be the query and second to be the field.
>
>Thanks
>
>Regards
>Sunil
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Re: lucene query (sql kind)

Posted by sunil goyal <su...@gmail.com>.
Hello,

I was just trying that...

QueryParser qp = new QueryParser("field AND field", new StandardAnalyzer());
Query query = qp.parse("name:\"john\" AND age:[10 TO 16]");

It works fine with this. Do I need to specify that QueryParser should
expect things in order
"field AND field". Or can I do without it?

The static method of QueryParser.parse(String , String, Analyzer) -
expects the first string to be the query and second to be the field.

Thanks

Regards
Sunil

On Fri, 28 Jan 2005 12:54:27 +0100, David Escuer
<da...@simpple.com> wrote:
> 
> Hello,
>    To build queries, you can generate a query like.... "(text:house OR
> text:car) AND (keywords:building)", and then
>    parse it with the QueryParser.parse method to get the Lucene query.
> Is not 100% sql-like syntax, but it's more clear
>    than the lucene syntax.
> 
> Hope it helps
> 
> David
> 
> sunil goyal wrote:
> 
> >Hello all,
> >
> >I want to run dynamic queries against the lucene index. Is there any
> >native syntax available for Lucene so that I can query, by first
> >generating the query in say an XML or SQL like format (cache this
> >query) and then  use this query over lucene index.
> >
> >
> >e.g. So a lucene query syntax in which I can define a query
> >(name="john" AND age <10)  and then I can just use this query to
> >execute over Lucene index.
> >
> >
> >Regards
> >Sunil
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: lucene-user-help@jakarta.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Re: lucene query (sql kind)

Posted by David Escuer <da...@simpple.com>.
Hello,
   To build queries, you can generate a query like.... "(text:house OR 
text:car) AND (keywords:building)", and then
   parse it with the QueryParser.parse method to get the Lucene query. 
Is not 100% sql-like syntax, but it's more clear
   than the lucene syntax.

Hope it helps

David

sunil goyal wrote:

>Hello all,
>
>I want to run dynamic queries against the lucene index. Is there any
>native syntax available for Lucene so that I can query, by first
>generating the query in say an XML or SQL like format (cache this
>query) and then  use this query over lucene index.
>
>
>e.g. So a lucene query syntax in which I can define a query
>(name="john" AND age <10)  and then I can just use this query to
>execute over Lucene index.
>
>
>Regards
>Sunil
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Re: lucene query (sql kind)

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
Ross - I'm really perplexed by your message.  You create HTML from a 
database so that you can index it with Lucene, yet wish you could 
simply index the data in your database tied to a primary key directly, 
right?

Well, you're in luck - you already can do this!

What are you using for indexing?  It sounds like you borrowed the 
Lucene demo and have just run with that directly.

	Erik


On Jan 28, 2005, at 11:02 AM, Ross Rankin wrote:

> I agree.  My site is all dynamic pages created from the database.  
> Right
> now, I have to have a process create dummy pages, index them with 
> Lucene,
> then translate the Lucene results into meaningful links.  It actually 
> works
> better than it sounds, however it could be easier.
>
> If I could just give Lucene a query result (i.e. a list of rows) and 
> then
> have Lucene send me back say the primary key of the rows that match 
> and the
> other Lucene goodness: ranking, number of hits, etc.
>
> Could be pretty powerful and simplify the deployment for database 
> driven
> applications.
>
> [Note: this opinion and $3.00 will get you a coffee at Starbucks]
>
> Ross
>
> -----Original Message-----
> From: PA [mailto:petite.abeille@gmail.com]
> Sent: Friday, January 28, 2005 6:44 AM
> To: Lucene Users List
> Subject: Re: lucene query (sql kind)
>
>
> On Jan 28, 2005, at 12:40, sunil goyal wrote:
>
>> I want to run dynamic queries against the lucene index. Is there any
>> native syntax available for Lucene so that I can query, by first
>> generating the query in say an XML or SQL like format (cache this
>> query) and then  use this query over lucene index.
>
> Talking of which, did anyone contemplated the possibility of a
> <gasp>JDBC</gasp> adaptor of sort for Lucene?
>
> Cheers
>
> --
> PA, Onnay Equitursay
> http://alt.textdrive.com/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


RE: lucene query (sql kind)

Posted by Ross Rankin <ro...@commercescience.com>.
I agree.  My site is all dynamic pages created from the database.  Right
now, I have to have a process create dummy pages, index them with Lucene,
then translate the Lucene results into meaningful links.  It actually works
better than it sounds, however it could be easier.

If I could just give Lucene a query result (i.e. a list of rows) and then
have Lucene send me back say the primary key of the rows that match and the
other Lucene goodness: ranking, number of hits, etc. 

Could be pretty powerful and simplify the deployment for database driven
applications.   

[Note: this opinion and $3.00 will get you a coffee at Starbucks]

Ross

-----Original Message-----
From: PA [mailto:petite.abeille@gmail.com] 
Sent: Friday, January 28, 2005 6:44 AM
To: Lucene Users List
Subject: Re: lucene query (sql kind)


On Jan 28, 2005, at 12:40, sunil goyal wrote:

> I want to run dynamic queries against the lucene index. Is there any
> native syntax available for Lucene so that I can query, by first
> generating the query in say an XML or SQL like format (cache this
> query) and then  use this query over lucene index.

Talking of which, did anyone contemplated the possibility of a 
<gasp>JDBC</gasp> adaptor of sort for Lucene?

Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Re: lucene query (sql kind)

Posted by PA <pe...@gmail.com>.
On Jan 28, 2005, at 12:40, sunil goyal wrote:

> I want to run dynamic queries against the lucene index. Is there any
> native syntax available for Lucene so that I can query, by first
> generating the query in say an XML or SQL like format (cache this
> query) and then  use this query over lucene index.

Talking of which, did anyone contemplated the possibility of a 
<gasp>JDBC</gasp> adaptor of sort for Lucene?

Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org