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 darul <da...@gmail.com> on 2011/10/26 22:36:03 UTC

Get results ordered by field content starting with specific word

I have seen many threads talking about it but not found any way on how to
resolve it.

In my schema 2 fields :



Results are sorted by field2 desc like in the following listing when looking
for "word1" as query pattern:



I would like to get Doc3 at the end because "word1" is not at the beginning
of the field content.

Have you any idea ? 

I have seen SpanNearQuery, tried FuzzySearch with no success etc...maybe
making a special QueryParserPlugin, but I am lost ;)

We use Solr 3.4

Thanks

--
View this message in context: http://lucene.472066.n3.nabble.com/Get-results-ordered-by-field-content-starting-with-specific-word-tp3455754p3455754.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Get results ordered by field content starting with specific word

Posted by darul <da...@gmail.com>.
Meaning I need to implement my own QueryParser ?

--
View this message in context: http://lucene.472066.n3.nabble.com/Get-results-ordered-by-field-content-starting-with-specific-word-tp3455754p3459064.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Get results ordered by field content starting with specific word

Posted by Ahmet Arslan <io...@yahoo.com>.
> Well, at indexed time I can not touch
> because we do not have data to index
> anymore.
> 
> To use SpanFirstQuery, I need to make a custom ParserQuery
> ?

If re-index is not an option, then writing custom is necessary to use SpanFirstQuery. You need to add it as an optional clause (with high boost) your whole boolean query. 

Also you can try and vote SOLR-839. With it it may be possible to use SpanFirstQuery.

https://issues.apache.org/jira/browse/SOLR-839

Re: Get results ordered by field content starting with specific word

Posted by darul <da...@gmail.com>.
Well, at indexed time I can not touch because we do not have data to index
anymore.

To use SpanFirstQuery, I need to make a custom ParserQuery ?

--
View this message in context: http://lucene.472066.n3.nabble.com/Get-results-ordered-by-field-content-starting-with-specific-word-tp3455754p3457167.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Get results ordered by field content starting with specific word

Posted by Ahmet Arslan <io...@yahoo.com>.

--- On Wed, 10/26/11, darul <da...@gmail.com> wrote:

> From: darul <da...@gmail.com>
> Subject: Get results ordered by field content starting with specific word
> To: solr-user@lucene.apache.org
> Date: Wednesday, October 26, 2011, 11:36 PM
> I have seen many threads talking
> about it but not found any way on how to
> resolve it.
> 
> In my schema 2 fields :
> 
> 
> 
> Results are sorted by field2 desc like in the following
> listing when looking
> for "word1" as query pattern:
> 
> 
> 
> I would like to get Doc3 at the end because "word1" is not
> at the beginning
> of the field content.
> 
> Have you any idea ? 
> 
> I have seen SpanNearQuery, tried FuzzySearch with no
> success etc...maybe
> making a special QueryParserPlugin, but I am lost ;)

May be you can make use of SpanFirstQuery.

http://lucene.apache.org/java/3_1_0/api/core/org/apache/lucene/search/spans/SpanFirstQuery.html

However, I would insert an artificial token (e.g. BEGIN_OF_DOC) before indexing my fields. And use a phrase query or something to boost documents starts with word1. e.g. "BEGIN_OF_DOC word1"