lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ahmet Arslan <iori...@yahoo.com>
Subject Re: World order sensitivity query id Solr
Date Wed, 18 Aug 2010 13:34:14 GMT
> First I very sorry form my bad English :/
> 
> I am new user of Apache Solr. I have read documentation and
> check
> Google, but I can not find solution of my problem:
> I need "words order sensitivity" query, for example I have
> two
> documents in Solr index:
> 1. one something two something three something four
> 2. four something three something two something one
> and I run query:
> 
> a)
> query: one AND two
> I want in result:
> 1. one something two something three something four - "one"
> is before
> "two", just like in query
> 2. four something three something two something one - I
> don't need
> this result, but it don't disturb if it is returned
> 
> b)
> query: two AND one
> I want in result:
> 1. four something three something two something one - "one"
> is after
> "two", just like in query
> 2. one something two something three something four - I
> don't need
> this result, but it don't disturb if it is returned
> 
> Is it possible? If yes, how?

It is possible but not out-of-the-box. You need to override SolrQueryParser so that it returns
SpanNearQuery instead of PhraseQuery. SpanNearQuery can do ordered proximity search. With
a slop of Integer.MAX you can achieve what you want. "one two"~Integer.MAX

Lucene in Action Book has a code listing for this task. (replacing SpanNearQuery with PhraseQuery)
You can copy and use it.


      

Mime
View raw message