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 Moiz Bhukhiya <mo...@gmail.com> on 2010/08/13 01:19:37 UTC

SOLR Query

Hi there,


I've a problem querying SOLR for a specific field with a query string that
contains spaces. I added following lines in the schema.xml to add my own
defined fields. Fields are: ap_name, ap_address, ap_dob, ap_desg, ap_sec.

Since all these fields are beginning with ap_, I included the the following
dynamicField.
<dynamicField name="*ap_*" type="text" indexed="true" stored="true"/>


I included this line to make a query for all fields instead of a specfic
field.
<copyField source="ap_*" dest="text"/>

I added the following document in my index:

<add>
<doc>
<field name="id">1</field>
<field name="ap_name">Tom Cruise</field>
<field name="ap_address">San Fransisco</field>
</doc>
</add>

1. When I query q=Tom+Cruise, I should get the above document since it is
available in "text" which ic my default query field. [Works as expected]
2. When I query q=ap_address:Tom, I should not get the above document since
Tom is not available in ap_address. [Works as expected]
3. When I query q=ap_address:Tom+Cruise, I shouldnt not get the above
document BUT I GET IT. {Doesnt work as expected]

Could anyone please explain me what mistake I am making?

Thanks alot, appreciate any help!
Moiz

Re: SOLR Query

Posted by Moiz Bhukhiya <mo...@gmail.com>.
I tried ap_address:(tom+cruise) and that worked. I am sure its the same
problem as you suspected!

Thanks a lot Erick(& users!) for your time.
Moiz

On Thu, Aug 12, 2010 at 8:51 PM, Erick Erickson <er...@gmail.com>wrote:

> You'll get a lot of insight into what's actually happening if you append
> &debugQuery=true to your queries, or check the "debug" checkbox
> in the solr admin page.
>
> But I suspect (and it's a guess since you haven't included your schema)
> that your problem is that you're mixing explicit and default fields.
> Something
> like "q=ap_address:Tom+Cruise", I think, gets parsed into something like
> ap_address:tom + default_field:cruise
>
> What happens if you try ap_address:(tom +cruise)?
>
> Best
> Erick
>
> On Thu, Aug 12, 2010 at 7:19 PM, Moiz Bhukhiya <moiz.bhukhiya@gmail.com
> >wrote:
>
> > Hi there,
> >
> >
> > I've a problem querying SOLR for a specific field with a query string
> that
> > contains spaces. I added following lines in the schema.xml to add my own
> > defined fields. Fields are: ap_name, ap_address, ap_dob, ap_desg, ap_sec.
> >
> > Since all these fields are beginning with ap_, I included the the
> following
> > dynamicField.
> > <dynamicField name="*ap_*" type="text" indexed="true" stored="true"/>
> >
> >
> > I included this line to make a query for all fields instead of a specfic
> > field.
> > <copyField source="ap_*" dest="text"/>
> >
> > I added the following document in my index:
> >
> > <add>
> > <doc>
> > <field name="id">1</field>
> > <field name="ap_name">Tom Cruise</field>
> > <field name="ap_address">San Fransisco</field>
> > </doc>
> > </add>
> >
> > 1. When I query q=Tom+Cruise, I should get the above document since it is
> > available in "text" which ic my default query field. [Works as expected]
> > 2. When I query q=ap_address:Tom, I should not get the above document
> since
> > Tom is not available in ap_address. [Works as expected]
> > 3. When I query q=ap_address:Tom+Cruise, I shouldnt not get the above
> > document BUT I GET IT. {Doesnt work as expected]
> >
> > Could anyone please explain me what mistake I am making?
> >
> > Thanks alot, appreciate any help!
> > Moiz
> >
>

Re: SOLR Query

Posted by Erick Erickson <er...@gmail.com>.
You'll get a lot of insight into what's actually happening if you append
&debugQuery=true to your queries, or check the "debug" checkbox
in the solr admin page.

But I suspect (and it's a guess since you haven't included your schema)
that your problem is that you're mixing explicit and default fields.
Something
like "q=ap_address:Tom+Cruise", I think, gets parsed into something like
ap_address:tom + default_field:cruise

What happens if you try ap_address:(tom +cruise)?

Best
Erick

On Thu, Aug 12, 2010 at 7:19 PM, Moiz Bhukhiya <mo...@gmail.com>wrote:

> Hi there,
>
>
> I've a problem querying SOLR for a specific field with a query string that
> contains spaces. I added following lines in the schema.xml to add my own
> defined fields. Fields are: ap_name, ap_address, ap_dob, ap_desg, ap_sec.
>
> Since all these fields are beginning with ap_, I included the the following
> dynamicField.
> <dynamicField name="*ap_*" type="text" indexed="true" stored="true"/>
>
>
> I included this line to make a query for all fields instead of a specfic
> field.
> <copyField source="ap_*" dest="text"/>
>
> I added the following document in my index:
>
> <add>
> <doc>
> <field name="id">1</field>
> <field name="ap_name">Tom Cruise</field>
> <field name="ap_address">San Fransisco</field>
> </doc>
> </add>
>
> 1. When I query q=Tom+Cruise, I should get the above document since it is
> available in "text" which ic my default query field. [Works as expected]
> 2. When I query q=ap_address:Tom, I should not get the above document since
> Tom is not available in ap_address. [Works as expected]
> 3. When I query q=ap_address:Tom+Cruise, I shouldnt not get the above
> document BUT I GET IT. {Doesnt work as expected]
>
> Could anyone please explain me what mistake I am making?
>
> Thanks alot, appreciate any help!
> Moiz
>