Thanks Erick. 

Right, if there is no slop specified it is like have an "exact match".  So I 
can simplify the query in:

bq=field1:("X A" OR "A B" OR "B Y")^10 

I'm struggling to understand if there is any way to split the user query in 
pairs directly with solr.

> On Sat, Nov 4, 2017 at 6:32 PM, Erick Erickson <erickerick...@gmail.com> 
> wrote:
> Looks good to me. The only thing I'd mention is that in the example
> given, complexprhase query is unnecessary, but only because there's no
> "slop" specified. If by "near" you can also mean "within 3 words" or
> some such, then you need complexPhraseQuery..
> 
> FWIW,
> Erick
> 
> On Sat, Nov 4, 2017 at 10:12 AM, Vincenzo D'Amore <v.dam...@gmail.com> wrote:
> > Hi,
> >
> > I have a field field1 where there are only pairs of terms, for example the
> > documents
> >
> > doc1 { field1 : "A B", title : "Hello title 1" }
> > doc2 { field1 : "A C", title : "Hello title 2"  }
> > doc3 { field1 : "A D", title : "Hello title 3"  }
> > doc4 { field1 : "B D", title : "Hello title 4"  }
> >
> > I have to boost the documents where there is a pair terms in the same order
> > used in the query:
> >
> > To be clear, if I the user search four terms: X A B Y
> >
> > I have to check they are in a field:
> >
> > X near A, A near B,  B near Y:
> >
> > I've implemented this problem using complexphrase:
> >
> > bq={!complexphrase inOrder=true df=field1}("X A" OR "A B" OR "B Y")^10
> >
> > What do you think of this solution? Is there another solution, may be using
> > a different query parser?
> >
> > Trying another way, I've also used with surround query parser, but I think,
> > I was unable to write the query correctly, never matches.
> >
> > bq={!surround}field1:(W(X, A) OR W(A,B) OR W(B, Y))^10
> >
> > Not sure if this is the correct syntax, I've also not found enough
> > documentation that explaining.
> >
> > Best regards,
> > Vincenzo



-- 
Vincenzo D'Amore
email: v.dam...@gmail.com
skype: free.dev
mobile: +39 349 8513251

Reply via email to