Use "sloppy phrase search". Treat a query without quotes as if quoted and then add a phrase qyery slop parameter that is no more that the position increment gap. For example,

Treat:

Eric solrUser

as:

"Eric solrUser"~100

That should not match your second document. But,

"Eric solrUser"~102

would match.

-- Jack Krupansky

-----Original Message----- From: Nirali Mehta
Sent: Monday, February 10, 2014 3:13 PM
To: solr-user@lucene.apache.org
Subject: Re: positionIncrementGap in schema.xml - Doesn't seem to work

Erick,
Here is the example.

There is a multivalued field 'name'.
1 document has following fields
1. Erick Erickson
2. Kashish Solruser
3. Some other user

2nd doc has following fields.
1. Erickson Eric
2. SolrUser Kashish

Now we have designed our app in such a way that
-> if the user gives any input within double quotes, we make the search as
such as in EXACT phrase in the EXACT order. So now if i search for "Erick
Erickson" , I get this 1st document only as output.
-> If the user gives just Erick Erickson without quotes, then we form the
query with AND clause and fetch the result. So my query will be
q=(name:(Eric) AND name=(Erickson)). I get the both the documents now.

Now i will show you where i face the problem.
-> If the user gives within quotes, i needn worry as the exact match
definetly doesn't fetch me the result and also the positionIncrementGap of
100 saves me.
-> If the user gives the input as Eric solrUser without quotes, i still
get the first document as i form the boolean query. here like you pinted
out positionIncrementGap plays no role. So now what do i do to prevent it
from coming?

The reason why i mentioned JOINS was to put this multivalued field in
seperate collection and JOIN to fetch the result. This way no way this
problem might come. But is this the right way?

Thanks.


On Mon, Feb 10, 2014 at 11:33 AM, Erick Erickson <erickerick...@gmail.com>wrote:

Nirali:

I really have no clue what you're trying to accomplish. Some examples
of inputs and outputs would help. I really don't understand what
multivalued fields have to do with your problem statement, it seems
like you're getting the expected behavior. What's happening that
shouldn't?

Joins don't seem relevant at all.

So I'm obviously missing something.

Best,
Erick


On Mon, Feb 10, 2014 at 10:36 AM, Nirali Mehta <nirali...@gmail.com>
wrote:

> Erick,
> I understand what you explaining to me. Let em point out few stuffs that
i
> face W.R.T my field type that i mentioned in my first mail.
>
> 1. If the user explicityly gives double quotes, we search for exact
phrases
> in exact order.
> 2. If they don't, its understood that they would just want those wants > to > be found in any other but include both the words. If i give the phrase > as > such without qiotes, my parser returns results even if one word is > found,
> So i introduce boolean 'AND' clause to seperate them.
> 3. And now i face this problem in multivalued fields.
>
> I understand i cannot nake use of positionIncrementGap now. But is can u
> tell me some alternative?
> All i can think of is 'JOINS' now. Whcih works pretty well. But is that > a
> good approach?
>
> Thanks.
> On Mon, Feb 10, 2014 at 8:15 AM, Erick Erickson <erickerick...@gmail.com
> >wrote:
>
> > OK, nothing in that parsed query will respect positionIncrementGap.
That
> is
> > only
> > relevant for _phrase_ queries and has no relevance to regular Boolean
> > queries.
> >
> > Using positionIncrementGap to keep matches from occurring across the
gaps
> > in
> > multiValued field requires phrases and slop. I.e. lets say your gap is
> 100.
> > Let's
> > say you've indexed the following two values
> >
> > Erick Erickson
> > Kashish Solruser
> >
> > Searching as you are for just +Erick +Kashish in the same field is > > only
> > asking
> > whether the terms appear anywhere and you'll get a match. Searching > > for
> > "Erick Kashish" (with quotes) will fail because the positions are
> roughly 1
> > and 103.
> > Likewise, searching "Erick Kashish"~100 will fail.
> >
> > Searching for "Erick Kashish"~110 will succeed because those two terms
> are
> > less than 110 positions apart.
> >
> > So I really think you're misunderstanding the use of
> positionIncrementGap.
> > What,
> > from a high level, are you trying to accomplish?
> >
> > Best,
> > Erick
> >
> >
> > On Sun, Feb 9, 2014 at 7:19 PM, Kashish <nirali...@gmail.com> wrote:
> >
> > > Hi Erik,
> > > Thanks for your reply.
> > >
> > > I am not using exact phrases here as i need to incorporate various
> forms
> > of
> > > searches. So i seperate the user input by 'AND clauses if the user
> > > exclusively doesn't ask for exact match.
> > >
> > > I use the query as
> > >
> > >
> >
>
http://localhost:8983/solr/all/select?q=%28akaName:%28a%29%20AND%20akaName:%28team%29%29&debug=true
> > >  and my debug gives me
> > > <str name="rawquerystring">(akaName:(a) AND > > > akaName:(team))</str><str
> > > name="querystring">(akaName:(a) AND akaName:(team))</str><str
> > > name="parsedquery">(+(+akaName:a +akaName:team))/no_coord</str><str
> > > name="parsedquery_toString">+(+akaName:a +akaName:team)</str>
> > >
> > > Is there any other better approach you suggest to me in this case?
> > >
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > >
> >
>
http://lucene.472066.n3.nabble.com/positionIncrementGap-in-schema-xml-Doesn-t-seem-to-work-tp4116405p4116408.html
> >  > Sent from the Solr - User mailing list archive at Nabble.com.
> > >
> >
>


Reply via email to