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 John Nielsen <jn...@mcb.dk> on 2014/09/11 13:34:55 UTC

q and logical operators.

q and logical operators.

Hi all,

I have a strange problem which seems to stomp my google-fu skills.

We have a webshop which has a solr based search mechanism which allows
customers to search for products based on a range of different fields,
including item numbers. I recently added a feature which allows users who
are logged in to search for custom item numbers which are associated with
that user. What this means in practical terms is that when a user logs in,
the solr search query has to look in one extra field compared to when the
user is not logged in.

The standard non-logged in search query looks like this (I only included
the relevant first part of the query.):
http://
<secret>/solr/11731_Danish/search?defType=edismax&q=Visitkort+display+Durable+4+rum+til+240+kort

When doing the same search while logged in, the query looks like this:
http://
<secret>/solr/11731_Danish/search?defType=edismax&q=Visitkort+display+Durable+4+rum+til+240+kort+OR+customer_5266762_product_number_string:Visitkort+display+Durable+4+rum+til+240+kort

Here I add an extra field, customer_5266762_product_number_string (5266762
being the logged in users internal ID), basically including the same search
tearm two times.

The above examples work beautifully when searching for a specific item
number stored in the customer_5266762_product_number_string. The problem is
that when a user is logged in and want to do regular searches, the system
begins to break down. In the specific example above, I expect to get a
single hit for a product with the title "Visitkort display Durable 4 rum
til 240 kort". It works as expected with the first non-logged-in example.
The second logged-in example returns over 7000 hits. I would expect it to
return just one hit since there is nothing relevant in the
customer_5266762_product_number_string for this query.

Now, the following is where my brain begins to melt down.

I discovered that if you put the search text in quotation marks, it will
work as expected, but doing so breaks another loved feature we have:

If i want a hit on the product named "Visitkort display Durable 4 rum til
240 kort", I could do a search for "vis dis dur", and it would show up. I
could also get a hit if i write "vis dur dis", changing the orden of the
words. If i put the search query in quotation marks, I break that
capability. I would get a hit for "vis dis dur", but "vis dur dis" no
longer returns anything. This is not an option for me.

It is entirely posible that there is a better way of implementing this and
fortunately, a rewrite is possible at this time. If my basic approach is
correct and I just don't understand how to construct my query correctly, an
RTFM pointer will be most welcome!

-- 
Med venlig hilsen / Best regards

*John Nielsen*
Programmer



*MCB A/S*
Enghaven 15
DK-7500 Holstebro

Kundeservice: +45 9610 2824
post@mcb.dk
www.mcb.dk

Re: q and logical operators.

Posted by John Nielsen <jn...@mcb.dk>.
Thanks for the heads up.

On Fri, Sep 12, 2014 at 5:48 PM, Erick Erickson <er...@gmail.com>
wrote:

> John:
>
> Glad it worked. Bit a little careful with large slops. As the slop
> increases, you approach the same result set as
>
> vis AND dis AND dur
>
> so choosing the appropriate slop is something of a balancing act
>
> Best,
> Erick
>
> On Fri, Sep 12, 2014 at 2:10 AM, John Nielsen <jn...@mcb.dk> wrote:
> > I didn't know about sloppy queries. This is great stuff!
> >
> > I solved it with a &qs=100.
> >
> > Thank you for the help.
> >
> >
> >
> > On Thu, Sep 11, 2014 at 11:36 PM, Erick Erickson <
> erickerickson@gmail.com>
> > wrote:
> >
> >> just skimmed, but:
> >>
> >> bq:  I would get a hit for "vis dis dur", but "vis dur dis" no longer
> >> returns anything. This is not an option for me
> >>
> >> Would slop help here? i.e. "vis dur dis"~3 or some such?
> >>
> >> Best
> >> Erick
> >>
> >> On Thu, Sep 11, 2014 at 4:34 AM, John Nielsen <jn...@mcb.dk> wrote:
> >> > q and logical operators.
> >> >
> >> > Hi all,
> >> >
> >> > I have a strange problem which seems to stomp my google-fu skills.
> >> >
> >> > We have a webshop which has a solr based search mechanism which allows
> >> > customers to search for products based on a range of different fields,
> >> > including item numbers. I recently added a feature which allows users
> who
> >> > are logged in to search for custom item numbers which are associated
> with
> >> > that user. What this means in practical terms is that when a user logs
> >> in,
> >> > the solr search query has to look in one extra field compared to when
> the
> >> > user is not logged in.
> >> >
> >> > The standard non-logged in search query looks like this (I only
> included
> >> > the relevant first part of the query.):
> >> > http://
> >> >
> >>
> <secret>/solr/11731_Danish/search?defType=edismax&q=Visitkort+display+Durable+4+rum+til+240+kort
> >> >
> >> > When doing the same search while logged in, the query looks like this:
> >> > http://
> >> >
> >>
> <secret>/solr/11731_Danish/search?defType=edismax&q=Visitkort+display+Durable+4+rum+til+240+kort+OR+customer_5266762_product_number_string:Visitkort+display+Durable+4+rum+til+240+kort
> >> >
> >> > Here I add an extra field, customer_5266762_product_number_string
> >> (5266762
> >> > being the logged in users internal ID), basically including the same
> >> search
> >> > tearm two times.
> >> >
> >> > The above examples work beautifully when searching for a specific item
> >> > number stored in the customer_5266762_product_number_string. The
> problem
> >> is
> >> > that when a user is logged in and want to do regular searches, the
> system
> >> > begins to break down. In the specific example above, I expect to get a
> >> > single hit for a product with the title "Visitkort display Durable 4
> rum
> >> > til 240 kort". It works as expected with the first non-logged-in
> example.
> >> > The second logged-in example returns over 7000 hits. I would expect
> it to
> >> > return just one hit since there is nothing relevant in the
> >> > customer_5266762_product_number_string for this query.
> >> >
> >> > Now, the following is where my brain begins to melt down.
> >> >
> >> > I discovered that if you put the search text in quotation marks, it
> will
> >> > work as expected, but doing so breaks another loved feature we have:
> >> >
> >> > If i want a hit on the product named "Visitkort display Durable 4 rum
> til
> >> > 240 kort", I could do a search for "vis dis dur", and it would show
> up. I
> >> > could also get a hit if i write "vis dur dis", changing the orden of
> the
> >> > words. If i put the search query in quotation marks, I break that
> >> > capability. I would get a hit for "vis dis dur", but "vis dur dis" no
> >> > longer returns anything. This is not an option for me.
> >> >
> >> > It is entirely posible that there is a better way of implementing this
> >> and
> >> > fortunately, a rewrite is possible at this time. If my basic approach
> is
> >> > correct and I just don't understand how to construct my query
> correctly,
> >> an
> >> > RTFM pointer will be most welcome!
> >> >
> >> > --
> >> > Med venlig hilsen / Best regards
> >> >
> >> > *John Nielsen*
> >> > Programmer
> >> >
> >> >
> >> >
> >> > *MCB A/S*
> >> > Enghaven 15
> >> > DK-7500 Holstebro
> >> >
> >> > Kundeservice: +45 9610 2824
> >> > post@mcb.dk
> >> > www.mcb.dk
> >>
> >
> >
> >
> > --
> > Med venlig hilsen / Best regards
> >
> > *John Nielsen*
> > Programmer
> >
> >
> >
> > *MCB A/S*
> > Enghaven 15
> > DK-7500 Holstebro
> >
> > Kundeservice: +45 9610 2824
> > post@mcb.dk
> > www.mcb.dk
>



-- 
Med venlig hilsen / Best regards

*John Nielsen*
Programmer



*MCB A/S*
Enghaven 15
DK-7500 Holstebro

Kundeservice: +45 9610 2824
post@mcb.dk
www.mcb.dk

Re: q and logical operators.

Posted by Erick Erickson <er...@gmail.com>.
John:

Glad it worked. Bit a little careful with large slops. As the slop
increases, you approach the same result set as

vis AND dis AND dur

so choosing the appropriate slop is something of a balancing act

Best,
Erick

On Fri, Sep 12, 2014 at 2:10 AM, John Nielsen <jn...@mcb.dk> wrote:
> I didn't know about sloppy queries. This is great stuff!
>
> I solved it with a &qs=100.
>
> Thank you for the help.
>
>
>
> On Thu, Sep 11, 2014 at 11:36 PM, Erick Erickson <er...@gmail.com>
> wrote:
>
>> just skimmed, but:
>>
>> bq:  I would get a hit for "vis dis dur", but "vis dur dis" no longer
>> returns anything. This is not an option for me
>>
>> Would slop help here? i.e. "vis dur dis"~3 or some such?
>>
>> Best
>> Erick
>>
>> On Thu, Sep 11, 2014 at 4:34 AM, John Nielsen <jn...@mcb.dk> wrote:
>> > q and logical operators.
>> >
>> > Hi all,
>> >
>> > I have a strange problem which seems to stomp my google-fu skills.
>> >
>> > We have a webshop which has a solr based search mechanism which allows
>> > customers to search for products based on a range of different fields,
>> > including item numbers. I recently added a feature which allows users who
>> > are logged in to search for custom item numbers which are associated with
>> > that user. What this means in practical terms is that when a user logs
>> in,
>> > the solr search query has to look in one extra field compared to when the
>> > user is not logged in.
>> >
>> > The standard non-logged in search query looks like this (I only included
>> > the relevant first part of the query.):
>> > http://
>> >
>> <secret>/solr/11731_Danish/search?defType=edismax&q=Visitkort+display+Durable+4+rum+til+240+kort
>> >
>> > When doing the same search while logged in, the query looks like this:
>> > http://
>> >
>> <secret>/solr/11731_Danish/search?defType=edismax&q=Visitkort+display+Durable+4+rum+til+240+kort+OR+customer_5266762_product_number_string:Visitkort+display+Durable+4+rum+til+240+kort
>> >
>> > Here I add an extra field, customer_5266762_product_number_string
>> (5266762
>> > being the logged in users internal ID), basically including the same
>> search
>> > tearm two times.
>> >
>> > The above examples work beautifully when searching for a specific item
>> > number stored in the customer_5266762_product_number_string. The problem
>> is
>> > that when a user is logged in and want to do regular searches, the system
>> > begins to break down. In the specific example above, I expect to get a
>> > single hit for a product with the title "Visitkort display Durable 4 rum
>> > til 240 kort". It works as expected with the first non-logged-in example.
>> > The second logged-in example returns over 7000 hits. I would expect it to
>> > return just one hit since there is nothing relevant in the
>> > customer_5266762_product_number_string for this query.
>> >
>> > Now, the following is where my brain begins to melt down.
>> >
>> > I discovered that if you put the search text in quotation marks, it will
>> > work as expected, but doing so breaks another loved feature we have:
>> >
>> > If i want a hit on the product named "Visitkort display Durable 4 rum til
>> > 240 kort", I could do a search for "vis dis dur", and it would show up. I
>> > could also get a hit if i write "vis dur dis", changing the orden of the
>> > words. If i put the search query in quotation marks, I break that
>> > capability. I would get a hit for "vis dis dur", but "vis dur dis" no
>> > longer returns anything. This is not an option for me.
>> >
>> > It is entirely posible that there is a better way of implementing this
>> and
>> > fortunately, a rewrite is possible at this time. If my basic approach is
>> > correct and I just don't understand how to construct my query correctly,
>> an
>> > RTFM pointer will be most welcome!
>> >
>> > --
>> > Med venlig hilsen / Best regards
>> >
>> > *John Nielsen*
>> > Programmer
>> >
>> >
>> >
>> > *MCB A/S*
>> > Enghaven 15
>> > DK-7500 Holstebro
>> >
>> > Kundeservice: +45 9610 2824
>> > post@mcb.dk
>> > www.mcb.dk
>>
>
>
>
> --
> Med venlig hilsen / Best regards
>
> *John Nielsen*
> Programmer
>
>
>
> *MCB A/S*
> Enghaven 15
> DK-7500 Holstebro
>
> Kundeservice: +45 9610 2824
> post@mcb.dk
> www.mcb.dk

Re: q and logical operators.

Posted by John Nielsen <jn...@mcb.dk>.
I didn't know about sloppy queries. This is great stuff!

I solved it with a &qs=100.

Thank you for the help.



On Thu, Sep 11, 2014 at 11:36 PM, Erick Erickson <er...@gmail.com>
wrote:

> just skimmed, but:
>
> bq:  I would get a hit for "vis dis dur", but "vis dur dis" no longer
> returns anything. This is not an option for me
>
> Would slop help here? i.e. "vis dur dis"~3 or some such?
>
> Best
> Erick
>
> On Thu, Sep 11, 2014 at 4:34 AM, John Nielsen <jn...@mcb.dk> wrote:
> > q and logical operators.
> >
> > Hi all,
> >
> > I have a strange problem which seems to stomp my google-fu skills.
> >
> > We have a webshop which has a solr based search mechanism which allows
> > customers to search for products based on a range of different fields,
> > including item numbers. I recently added a feature which allows users who
> > are logged in to search for custom item numbers which are associated with
> > that user. What this means in practical terms is that when a user logs
> in,
> > the solr search query has to look in one extra field compared to when the
> > user is not logged in.
> >
> > The standard non-logged in search query looks like this (I only included
> > the relevant first part of the query.):
> > http://
> >
> <secret>/solr/11731_Danish/search?defType=edismax&q=Visitkort+display+Durable+4+rum+til+240+kort
> >
> > When doing the same search while logged in, the query looks like this:
> > http://
> >
> <secret>/solr/11731_Danish/search?defType=edismax&q=Visitkort+display+Durable+4+rum+til+240+kort+OR+customer_5266762_product_number_string:Visitkort+display+Durable+4+rum+til+240+kort
> >
> > Here I add an extra field, customer_5266762_product_number_string
> (5266762
> > being the logged in users internal ID), basically including the same
> search
> > tearm two times.
> >
> > The above examples work beautifully when searching for a specific item
> > number stored in the customer_5266762_product_number_string. The problem
> is
> > that when a user is logged in and want to do regular searches, the system
> > begins to break down. In the specific example above, I expect to get a
> > single hit for a product with the title "Visitkort display Durable 4 rum
> > til 240 kort". It works as expected with the first non-logged-in example.
> > The second logged-in example returns over 7000 hits. I would expect it to
> > return just one hit since there is nothing relevant in the
> > customer_5266762_product_number_string for this query.
> >
> > Now, the following is where my brain begins to melt down.
> >
> > I discovered that if you put the search text in quotation marks, it will
> > work as expected, but doing so breaks another loved feature we have:
> >
> > If i want a hit on the product named "Visitkort display Durable 4 rum til
> > 240 kort", I could do a search for "vis dis dur", and it would show up. I
> > could also get a hit if i write "vis dur dis", changing the orden of the
> > words. If i put the search query in quotation marks, I break that
> > capability. I would get a hit for "vis dis dur", but "vis dur dis" no
> > longer returns anything. This is not an option for me.
> >
> > It is entirely posible that there is a better way of implementing this
> and
> > fortunately, a rewrite is possible at this time. If my basic approach is
> > correct and I just don't understand how to construct my query correctly,
> an
> > RTFM pointer will be most welcome!
> >
> > --
> > Med venlig hilsen / Best regards
> >
> > *John Nielsen*
> > Programmer
> >
> >
> >
> > *MCB A/S*
> > Enghaven 15
> > DK-7500 Holstebro
> >
> > Kundeservice: +45 9610 2824
> > post@mcb.dk
> > www.mcb.dk
>



-- 
Med venlig hilsen / Best regards

*John Nielsen*
Programmer



*MCB A/S*
Enghaven 15
DK-7500 Holstebro

Kundeservice: +45 9610 2824
post@mcb.dk
www.mcb.dk

Re: q and logical operators.

Posted by Erick Erickson <er...@gmail.com>.
just skimmed, but:

bq:  I would get a hit for "vis dis dur", but "vis dur dis" no longer
returns anything. This is not an option for me

Would slop help here? i.e. "vis dur dis"~3 or some such?

Best
Erick

On Thu, Sep 11, 2014 at 4:34 AM, John Nielsen <jn...@mcb.dk> wrote:
> q and logical operators.
>
> Hi all,
>
> I have a strange problem which seems to stomp my google-fu skills.
>
> We have a webshop which has a solr based search mechanism which allows
> customers to search for products based on a range of different fields,
> including item numbers. I recently added a feature which allows users who
> are logged in to search for custom item numbers which are associated with
> that user. What this means in practical terms is that when a user logs in,
> the solr search query has to look in one extra field compared to when the
> user is not logged in.
>
> The standard non-logged in search query looks like this (I only included
> the relevant first part of the query.):
> http://
> <secret>/solr/11731_Danish/search?defType=edismax&q=Visitkort+display+Durable+4+rum+til+240+kort
>
> When doing the same search while logged in, the query looks like this:
> http://
> <secret>/solr/11731_Danish/search?defType=edismax&q=Visitkort+display+Durable+4+rum+til+240+kort+OR+customer_5266762_product_number_string:Visitkort+display+Durable+4+rum+til+240+kort
>
> Here I add an extra field, customer_5266762_product_number_string (5266762
> being the logged in users internal ID), basically including the same search
> tearm two times.
>
> The above examples work beautifully when searching for a specific item
> number stored in the customer_5266762_product_number_string. The problem is
> that when a user is logged in and want to do regular searches, the system
> begins to break down. In the specific example above, I expect to get a
> single hit for a product with the title "Visitkort display Durable 4 rum
> til 240 kort". It works as expected with the first non-logged-in example.
> The second logged-in example returns over 7000 hits. I would expect it to
> return just one hit since there is nothing relevant in the
> customer_5266762_product_number_string for this query.
>
> Now, the following is where my brain begins to melt down.
>
> I discovered that if you put the search text in quotation marks, it will
> work as expected, but doing so breaks another loved feature we have:
>
> If i want a hit on the product named "Visitkort display Durable 4 rum til
> 240 kort", I could do a search for "vis dis dur", and it would show up. I
> could also get a hit if i write "vis dur dis", changing the orden of the
> words. If i put the search query in quotation marks, I break that
> capability. I would get a hit for "vis dis dur", but "vis dur dis" no
> longer returns anything. This is not an option for me.
>
> It is entirely posible that there is a better way of implementing this and
> fortunately, a rewrite is possible at this time. If my basic approach is
> correct and I just don't understand how to construct my query correctly, an
> RTFM pointer will be most welcome!
>
> --
> Med venlig hilsen / Best regards
>
> *John Nielsen*
> Programmer
>
>
>
> *MCB A/S*
> Enghaven 15
> DK-7500 Holstebro
>
> Kundeservice: +45 9610 2824
> post@mcb.dk
> www.mcb.dk