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 Aaron Gibbons <ag...@synergydatasystems.com> on 2015/10/30 20:27:00 UTC

Solr Keyword query on a specific field.

Is there any way to have a single field search use the same keyword search
logic as the default query? I define q.op as AND in my query which gets
applied to any main keywords but any keywords I'm trying to use within a
field do not get the same logic applied.
Example:
q=(title:(Test Keywords)) the space is treated as OR regardless of q.op
q=(Test Keywords) the space is defined by q.op which is AND

Using the correct operators (AND OR * - +...) it works great as I have it
defined. There's just this one little caveat when you use spaces between
keywords expecting the q.op operator to be applied.
Thanks,
Aaron

Re: Solr Keyword query on a specific field.

Posted by Aaron Gibbons <ag...@patriotsoftware.com>.
I apologize for the long delay in response.  I was able to get it to work
tho! Thank you!!

The local parameters were confusing to me at first. I'm using SolrNet to
build the search which has LocalParams that I am already specifying, but
those are not applied to the title portion.  What I ended up doing is
applying the local params like the link you provided suggested, basically
wrapping just the Title portion of the query.

So in SolrNet I did:
solrQueries.Add(new SolrQuery("{!q.op=AND mm=100% df=current_position_title
v='" + Title Keywords + "'}"));

And the Solr query ends up being:
{!q.op=AND+mm=100%+df=current_position_title+v='Title Keywords'}

Now users can enter their keywords or boolean string and it's working just
as a Solr keyword search does.  Exactly what I wanted!

I just have to figure out how to do the same thing using Sunspot tho.


On Sun, Nov 8, 2015 at 7:01 PM, davidphilip cherian <
davidphilipcherian@gmail.com> wrote:

> Nested queries might help.
>
> http://www.slideshare.net/erikhatcher/solr-query-parsing-tips-and-tricks
>
> On Mon, Nov 2, 2015 at 10:20 AM, Aaron Gibbons <
> agibbons@synergydatasystems.com> wrote:
>
> > The input for the title field is user based so a wide range of things can
> > be entered there.  Quoting the title is not what I'm looking for.  I also
> > checked and q.op is AND and MM is 100%.  In addition to the Title field
> the
> > user can also use general keywords so setting local params (df) to
> > something else would not work either to my knowledge.
> >
> > To give you a better idea of what I'm trying to accomplish: I have a form
> > to allow users to search on Title, Keywords and add a location. The
> correct
> > operators are applied between each of these and also for the main
> keywords
> > themselves.  The only issue is with the default operator being applied
> > within the Title sections's keywords. My goal is to have the Title
> keywords
> > work the same as the general keywords but only be applied to the title
> > field vs the default text field.
> >
> > On Fri, Oct 30, 2015 at 6:35 PM, davidphilip cherian <
> > davidphilipcherian@gmail.com> wrote:
> >
> > > >> "Is there any way to have a single field search use the same keyword
> > > search logic as the default query?"
> > > Do a phrase search, with double quotes surrounding the multiple
> keywords,
> > > it should work.
> > >
> > > Try q=title:("Test Keywords")
> > >
> > > You could possibly try adding this q.op as local param to query as
> shown
> > > below.
> > >
> > >
> >
> https://cwiki.apache.org/confluence/display/solr/Local+Parameters+in+Queries
> > >
> > > If you are using edismax query parser, check for what is mm pram
> > > set. q.op=AND => mm=100%; q.op=OR => mm=0%)
> > >
> > >
> >
> https://wiki.apache.org/solr/ExtendedDisMax#mm_.28Minimum_.27Should.27_Match.29
> > >
> > >
> > > On Fri, Oct 30, 2015 at 3:27 PM, Aaron Gibbons <
> > > agibbons@synergydatasystems.com> wrote:
> > >
> > > > Is there any way to have a single field search use the same keyword
> > > search
> > > > logic as the default query? I define q.op as AND in my query which
> gets
> > > > applied to any main keywords but any keywords I'm trying to use
> within
> > a
> > > > field do not get the same logic applied.
> > > > Example:
> > > > q=(title:(Test Keywords)) the space is treated as OR regardless of
> q.op
> > > > q=(Test Keywords) the space is defined by q.op which is AND
> > > >
> > > > Using the correct operators (AND OR * - +...) it works great as I
> have
> > it
> > > > defined. There's just this one little caveat when you use spaces
> > between
> > > > keywords expecting the q.op operator to be applied.
> > > > Thanks,
> > > > Aaron
> > > >
> > >
> >
>

Re: Solr Keyword query on a specific field.

Posted by davidphilip cherian <da...@gmail.com>.
Nested queries might help.

http://www.slideshare.net/erikhatcher/solr-query-parsing-tips-and-tricks

On Mon, Nov 2, 2015 at 10:20 AM, Aaron Gibbons <
agibbons@synergydatasystems.com> wrote:

> The input for the title field is user based so a wide range of things can
> be entered there.  Quoting the title is not what I'm looking for.  I also
> checked and q.op is AND and MM is 100%.  In addition to the Title field the
> user can also use general keywords so setting local params (df) to
> something else would not work either to my knowledge.
>
> To give you a better idea of what I'm trying to accomplish: I have a form
> to allow users to search on Title, Keywords and add a location. The correct
> operators are applied between each of these and also for the main keywords
> themselves.  The only issue is with the default operator being applied
> within the Title sections's keywords. My goal is to have the Title keywords
> work the same as the general keywords but only be applied to the title
> field vs the default text field.
>
> On Fri, Oct 30, 2015 at 6:35 PM, davidphilip cherian <
> davidphilipcherian@gmail.com> wrote:
>
> > >> "Is there any way to have a single field search use the same keyword
> > search logic as the default query?"
> > Do a phrase search, with double quotes surrounding the multiple keywords,
> > it should work.
> >
> > Try q=title:("Test Keywords")
> >
> > You could possibly try adding this q.op as local param to query as shown
> > below.
> >
> >
> https://cwiki.apache.org/confluence/display/solr/Local+Parameters+in+Queries
> >
> > If you are using edismax query parser, check for what is mm pram
> > set. q.op=AND => mm=100%; q.op=OR => mm=0%)
> >
> >
> https://wiki.apache.org/solr/ExtendedDisMax#mm_.28Minimum_.27Should.27_Match.29
> >
> >
> > On Fri, Oct 30, 2015 at 3:27 PM, Aaron Gibbons <
> > agibbons@synergydatasystems.com> wrote:
> >
> > > Is there any way to have a single field search use the same keyword
> > search
> > > logic as the default query? I define q.op as AND in my query which gets
> > > applied to any main keywords but any keywords I'm trying to use within
> a
> > > field do not get the same logic applied.
> > > Example:
> > > q=(title:(Test Keywords)) the space is treated as OR regardless of q.op
> > > q=(Test Keywords) the space is defined by q.op which is AND
> > >
> > > Using the correct operators (AND OR * - +...) it works great as I have
> it
> > > defined. There's just this one little caveat when you use spaces
> between
> > > keywords expecting the q.op operator to be applied.
> > > Thanks,
> > > Aaron
> > >
> >
>

Re: Solr Keyword query on a specific field.

Posted by Aaron Gibbons <ag...@synergydatasystems.com>.
The input for the title field is user based so a wide range of things can
be entered there.  Quoting the title is not what I'm looking for.  I also
checked and q.op is AND and MM is 100%.  In addition to the Title field the
user can also use general keywords so setting local params (df) to
something else would not work either to my knowledge.

To give you a better idea of what I'm trying to accomplish: I have a form
to allow users to search on Title, Keywords and add a location. The correct
operators are applied between each of these and also for the main keywords
themselves.  The only issue is with the default operator being applied
within the Title sections's keywords. My goal is to have the Title keywords
work the same as the general keywords but only be applied to the title
field vs the default text field.

On Fri, Oct 30, 2015 at 6:35 PM, davidphilip cherian <
davidphilipcherian@gmail.com> wrote:

> >> "Is there any way to have a single field search use the same keyword
> search logic as the default query?"
> Do a phrase search, with double quotes surrounding the multiple keywords,
> it should work.
>
> Try q=title:("Test Keywords")
>
> You could possibly try adding this q.op as local param to query as shown
> below.
>
> https://cwiki.apache.org/confluence/display/solr/Local+Parameters+in+Queries
>
> If you are using edismax query parser, check for what is mm pram
> set. q.op=AND => mm=100%; q.op=OR => mm=0%)
>
> https://wiki.apache.org/solr/ExtendedDisMax#mm_.28Minimum_.27Should.27_Match.29
>
>
> On Fri, Oct 30, 2015 at 3:27 PM, Aaron Gibbons <
> agibbons@synergydatasystems.com> wrote:
>
> > Is there any way to have a single field search use the same keyword
> search
> > logic as the default query? I define q.op as AND in my query which gets
> > applied to any main keywords but any keywords I'm trying to use within a
> > field do not get the same logic applied.
> > Example:
> > q=(title:(Test Keywords)) the space is treated as OR regardless of q.op
> > q=(Test Keywords) the space is defined by q.op which is AND
> >
> > Using the correct operators (AND OR * - +...) it works great as I have it
> > defined. There's just this one little caveat when you use spaces between
> > keywords expecting the q.op operator to be applied.
> > Thanks,
> > Aaron
> >
>

Re: Solr Keyword query on a specific field.

Posted by davidphilip cherian <da...@gmail.com>.
>> "Is there any way to have a single field search use the same keyword
search logic as the default query?"
Do a phrase search, with double quotes surrounding the multiple keywords,
it should work.

Try q=title:("Test Keywords")

You could possibly try adding this q.op as local param to query as shown
below.
https://cwiki.apache.org/confluence/display/solr/Local+Parameters+in+Queries

If you are using edismax query parser, check for what is mm pram
set. q.op=AND => mm=100%; q.op=OR => mm=0%)
https://wiki.apache.org/solr/ExtendedDisMax#mm_.28Minimum_.27Should.27_Match.29


On Fri, Oct 30, 2015 at 3:27 PM, Aaron Gibbons <
agibbons@synergydatasystems.com> wrote:

> Is there any way to have a single field search use the same keyword search
> logic as the default query? I define q.op as AND in my query which gets
> applied to any main keywords but any keywords I'm trying to use within a
> field do not get the same logic applied.
> Example:
> q=(title:(Test Keywords)) the space is treated as OR regardless of q.op
> q=(Test Keywords) the space is defined by q.op which is AND
>
> Using the correct operators (AND OR * - +...) it works great as I have it
> defined. There's just this one little caveat when you use spaces between
> keywords expecting the q.op operator to be applied.
> Thanks,
> Aaron
>