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 "Saler, Jeff" <JS...@ball.com> on 2011/04/29 19:40:55 UTC
querying in Java
Is there any way to query for data that is in any field, i.e. not using
a specific field name?
For example, when I use the following statements:
SolrQuery query = new SolrQuery();
Query.setQuery("ANALYST:John Schummers");
QueryResponse rsp = server.query(query);
I get the documents I'm looking for.
But I would like to get the same set of documents without using the
specific ANALYST field name.
I have tried using just "Schummers" as the query, but no documents are
returned.
The ANALYST field is an indexed field.
This message and any enclosures are intended only for the addressee. Please
notify the sender by email if you are not the intended recipient. If you are
not the intended recipient, you may not use, copy, disclose, or distribute this
message or its contents or enclosures to any other person and any such actions
may be unlawful. Ball reserves the right to monitor and review all messages
and enclosures sent to or from this email address.
Re: querying in Java
Posted by Otis Gospodnetic <ot...@yahoo.com>.
Jeff,
If I understand what you need, then:
yourFieldNameHere:(blue OR Tuesday)
Otis
----
Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch
Lucene ecosystem search :: http://search-lucene.com/
----- Original Message ----
> From: "Saler, Jeff" <JS...@ball.com>
> To: solr-user@lucene.apache.org
> Sent: Mon, May 2, 2011 1:24:52 PM
> Subject: RE: querying in Java
>
> This worked. Thank you.
>
> What if I want to query for two or more field's values. For example:
> Field color dayOf Week
>
> Value blue Tuesday
>
> I have tried a query string of "blue&Tuesday", with no success.
>
>
>
> -----Original Message-----
> From: Anuj Kumar [mailto:anujsays@gmail.com]
> Sent: Friday, April 29, 2011 2:10 PM
> To: solr-user@lucene.apache.org
> Subject: Re: querying in Java
>
> Hi Jeff,
>
> In that case, you can create a new index field (set indexed to true and
> stored to false) and copy all your fields to it using copyField.
> Also make this new field as your default search field.
>
> This will handle your case.
>
> Regards,
> Anuj
>
> On Fri, Apr 29, 2011 at 11:36 PM, Saler, Jeff <JS...@ball.com> wrote:
>
> > Thanks for the reply. What I want is for the query to search all
> fields
> > for the specified value.
> >
> > -----Original Message-----
> > From: Anuj Kumar [mailto:anujsays@gmail.com]
> > Sent: Friday, April 29, 2011 1:51 PM
> > To: solr-user@lucene.apache.org
> > Subject: Re: querying in Java
> >
> > Hi Jeff,
> >
> > In that case, it will query w.r.t default field. What is your default
> > search
> > field in the schema?
> >
> > Regards,
> > Anuj
> >
> > On Fri, Apr 29, 2011 at 11:10 PM, Saler, Jeff <JS...@ball.com> wrote:
> >
> > > Is there any way to query for data that is in any field, i.e. not
> > using
> > > a specific field name?
> > >
> > >
> > >
> > > For example, when I use the following statements:
> > >
> > >
> > >
> > > SolrQuery query = new SolrQuery();
> > >
> > > Query.setQuery("ANALYST:John Schummers");
> > >
> > > QueryResponse rsp = server.query(query);
> > >
> > >
> > >
> > >
> > >
> > > I get the documents I'm looking for.
> > >
> > >
> > >
> > > But I would like to get the same set of documents without using the
> > > specific ANALYST field name.
> > >
> > > I have tried using just "Schummers" as the query, but no documents
> are
> > > returned.
> > >
> > > The ANALYST field is an indexed field.
> > >
> > >
> > >
> > >
> > >
> > >
> > > This message and any enclosures are intended only for the addressee.
> > > Please
> > > notify the sender by email if you are not the intended recipient.
> If
> > you
> > > are
> > > not the intended recipient, you may not use, copy, disclose, or
> > distribute
> > > this
> > > message or its contents or enclosures to any other person and any
> such
> > > actions
> > > may be unlawful. Ball reserves the right to monitor and review all
> > > messages
> > > and enclosures sent to or from this email address.
> >
> >
> >
> > This message and any enclosures are intended only for the addressee.
> > Please
> > notify the sender by email if you are not the intended recipient. If
> you
> > are
> > not the intended recipient, you may not use, copy, disclose, or
> distribute
> > this
> > message or its contents or enclosures to any other person and any such
> > actions
> > may be unlawful. Ball reserves the right to monitor and review all
> > messages
> > and enclosures sent to or from this email address.
> >
>
>
>
> This message and any enclosures are intended only for the addressee. Please
>
> notify the sender by email if you are not the intended recipient. If you are
>
> not the intended recipient, you may not use, copy, disclose, or distribute
>this
>
> message or its contents or enclosures to any other person and any such
>actions
>
> may be unlawful. Ball reserves the right to monitor and review all messages
> and enclosures sent to or from this email address.
>
Re: querying in Java
Posted by Anuj Kumar <an...@gmail.com>.
Hi Jeff,
Either you can use a filter query or specify it explicitly,
like- "Field:Value OR color:blue OR dayOfWeek:Tuesday"
or use AND in between. It depends on what you want.
Also, if you don't want to specify AND/OR and decide on a global
declaration, then set it as the default operator in your schema.xml. For
example-
<solrQueryParser defaultOperator="OR"/>
Hope it helps.
Regards,
Anuj
On Mon, May 2, 2011 at 10:54 PM, Saler, Jeff <JS...@ball.com> wrote:
> This worked. Thank you.
>
> What if I want to query for two or more field's values. For example:
> Field color dayOf Week
>
> Value blue Tuesday
>
> I have tried a query string of "blue&Tuesday", with no success.
>
>
>
> -----Original Message-----
> From: Anuj Kumar [mailto:anujsays@gmail.com]
> Sent: Friday, April 29, 2011 2:10 PM
> To: solr-user@lucene.apache.org
> Subject: Re: querying in Java
>
> Hi Jeff,
>
> In that case, you can create a new index field (set indexed to true and
> stored to false) and copy all your fields to it using copyField.
> Also make this new field as your default search field.
>
> This will handle your case.
>
> Regards,
> Anuj
>
> On Fri, Apr 29, 2011 at 11:36 PM, Saler, Jeff <JS...@ball.com> wrote:
>
> > Thanks for the reply. What I want is for the query to search all
> fields
> > for the specified value.
> >
> > -----Original Message-----
> > From: Anuj Kumar [mailto:anujsays@gmail.com]
> > Sent: Friday, April 29, 2011 1:51 PM
> > To: solr-user@lucene.apache.org
> > Subject: Re: querying in Java
> >
> > Hi Jeff,
> >
> > In that case, it will query w.r.t default field. What is your default
> > search
> > field in the schema?
> >
> > Regards,
> > Anuj
> >
> > On Fri, Apr 29, 2011 at 11:10 PM, Saler, Jeff <JS...@ball.com> wrote:
> >
> > > Is there any way to query for data that is in any field, i.e. not
> > using
> > > a specific field name?
> > >
> > >
> > >
> > > For example, when I use the following statements:
> > >
> > >
> > >
> > > SolrQuery query = new SolrQuery();
> > >
> > > Query.setQuery("ANALYST:John Schummers");
> > >
> > > QueryResponse rsp = server.query(query);
> > >
> > >
> > >
> > >
> > >
> > > I get the documents I'm looking for.
> > >
> > >
> > >
> > > But I would like to get the same set of documents without using the
> > > specific ANALYST field name.
> > >
> > > I have tried using just "Schummers" as the query, but no documents
> are
> > > returned.
> > >
> > > The ANALYST field is an indexed field.
> > >
> > >
> > >
> > >
> > >
> > >
> > > This message and any enclosures are intended only for the addressee.
> > > Please
> > > notify the sender by email if you are not the intended recipient.
> If
> > you
> > > are
> > > not the intended recipient, you may not use, copy, disclose, or
> > distribute
> > > this
> > > message or its contents or enclosures to any other person and any
> such
> > > actions
> > > may be unlawful. Ball reserves the right to monitor and review all
> > > messages
> > > and enclosures sent to or from this email address.
> >
> >
> >
> > This message and any enclosures are intended only for the addressee.
> > Please
> > notify the sender by email if you are not the intended recipient. If
> you
> > are
> > not the intended recipient, you may not use, copy, disclose, or
> distribute
> > this
> > message or its contents or enclosures to any other person and any such
> > actions
> > may be unlawful. Ball reserves the right to monitor and review all
> > messages
> > and enclosures sent to or from this email address.
> >
>
>
>
> This message and any enclosures are intended only for the addressee.
> Please
> notify the sender by email if you are not the intended recipient. If you
> are
> not the intended recipient, you may not use, copy, disclose, or distribute
> this
> message or its contents or enclosures to any other person and any such
> actions
> may be unlawful. Ball reserves the right to monitor and review all
> messages
> and enclosures sent to or from this email address.
>
RE: querying in Java
Posted by "Saler, Jeff" <JS...@ball.com>.
This worked. Thank you.
What if I want to query for two or more field's values. For example:
Field color dayOf Week
Value blue Tuesday
I have tried a query string of "blue&Tuesday", with no success.
-----Original Message-----
From: Anuj Kumar [mailto:anujsays@gmail.com]
Sent: Friday, April 29, 2011 2:10 PM
To: solr-user@lucene.apache.org
Subject: Re: querying in Java
Hi Jeff,
In that case, you can create a new index field (set indexed to true and
stored to false) and copy all your fields to it using copyField.
Also make this new field as your default search field.
This will handle your case.
Regards,
Anuj
On Fri, Apr 29, 2011 at 11:36 PM, Saler, Jeff <JS...@ball.com> wrote:
> Thanks for the reply. What I want is for the query to search all
fields
> for the specified value.
>
> -----Original Message-----
> From: Anuj Kumar [mailto:anujsays@gmail.com]
> Sent: Friday, April 29, 2011 1:51 PM
> To: solr-user@lucene.apache.org
> Subject: Re: querying in Java
>
> Hi Jeff,
>
> In that case, it will query w.r.t default field. What is your default
> search
> field in the schema?
>
> Regards,
> Anuj
>
> On Fri, Apr 29, 2011 at 11:10 PM, Saler, Jeff <JS...@ball.com> wrote:
>
> > Is there any way to query for data that is in any field, i.e. not
> using
> > a specific field name?
> >
> >
> >
> > For example, when I use the following statements:
> >
> >
> >
> > SolrQuery query = new SolrQuery();
> >
> > Query.setQuery("ANALYST:John Schummers");
> >
> > QueryResponse rsp = server.query(query);
> >
> >
> >
> >
> >
> > I get the documents I'm looking for.
> >
> >
> >
> > But I would like to get the same set of documents without using the
> > specific ANALYST field name.
> >
> > I have tried using just "Schummers" as the query, but no documents
are
> > returned.
> >
> > The ANALYST field is an indexed field.
> >
> >
> >
> >
> >
> >
> > This message and any enclosures are intended only for the addressee.
> > Please
> > notify the sender by email if you are not the intended recipient.
If
> you
> > are
> > not the intended recipient, you may not use, copy, disclose, or
> distribute
> > this
> > message or its contents or enclosures to any other person and any
such
> > actions
> > may be unlawful. Ball reserves the right to monitor and review all
> > messages
> > and enclosures sent to or from this email address.
>
>
>
> This message and any enclosures are intended only for the addressee.
> Please
> notify the sender by email if you are not the intended recipient. If
you
> are
> not the intended recipient, you may not use, copy, disclose, or
distribute
> this
> message or its contents or enclosures to any other person and any such
> actions
> may be unlawful. Ball reserves the right to monitor and review all
> messages
> and enclosures sent to or from this email address.
>
This message and any enclosures are intended only for the addressee. Please
notify the sender by email if you are not the intended recipient. If you are
not the intended recipient, you may not use, copy, disclose, or distribute this
message or its contents or enclosures to any other person and any such actions
may be unlawful. Ball reserves the right to monitor and review all messages
and enclosures sent to or from this email address.
Re: querying in Java
Posted by Anuj Kumar <an...@gmail.com>.
Hi Jeff,
In that case, you can create a new index field (set indexed to true and
stored to false) and copy all your fields to it using copyField.
Also make this new field as your default search field.
This will handle your case.
Regards,
Anuj
On Fri, Apr 29, 2011 at 11:36 PM, Saler, Jeff <JS...@ball.com> wrote:
> Thanks for the reply. What I want is for the query to search all fields
> for the specified value.
>
> -----Original Message-----
> From: Anuj Kumar [mailto:anujsays@gmail.com]
> Sent: Friday, April 29, 2011 1:51 PM
> To: solr-user@lucene.apache.org
> Subject: Re: querying in Java
>
> Hi Jeff,
>
> In that case, it will query w.r.t default field. What is your default
> search
> field in the schema?
>
> Regards,
> Anuj
>
> On Fri, Apr 29, 2011 at 11:10 PM, Saler, Jeff <JS...@ball.com> wrote:
>
> > Is there any way to query for data that is in any field, i.e. not
> using
> > a specific field name?
> >
> >
> >
> > For example, when I use the following statements:
> >
> >
> >
> > SolrQuery query = new SolrQuery();
> >
> > Query.setQuery("ANALYST:John Schummers");
> >
> > QueryResponse rsp = server.query(query);
> >
> >
> >
> >
> >
> > I get the documents I'm looking for.
> >
> >
> >
> > But I would like to get the same set of documents without using the
> > specific ANALYST field name.
> >
> > I have tried using just "Schummers" as the query, but no documents are
> > returned.
> >
> > The ANALYST field is an indexed field.
> >
> >
> >
> >
> >
> >
> > This message and any enclosures are intended only for the addressee.
> > Please
> > notify the sender by email if you are not the intended recipient. If
> you
> > are
> > not the intended recipient, you may not use, copy, disclose, or
> distribute
> > this
> > message or its contents or enclosures to any other person and any such
> > actions
> > may be unlawful. Ball reserves the right to monitor and review all
> > messages
> > and enclosures sent to or from this email address.
>
>
>
> This message and any enclosures are intended only for the addressee.
> Please
> notify the sender by email if you are not the intended recipient. If you
> are
> not the intended recipient, you may not use, copy, disclose, or distribute
> this
> message or its contents or enclosures to any other person and any such
> actions
> may be unlawful. Ball reserves the right to monitor and review all
> messages
> and enclosures sent to or from this email address.
>
Re: querying in Java
Posted by Rob Casson <ro...@gmail.com>.
copyField should do the trick:
http://wiki.apache.org/solr/SchemaXml#Copy_Fields
"A common requirement is to copy or merge all input fields into a
single solr field. This can be done as follows:-
<copyField source="*" dest="text"/>"
hth,
rob
On Fri, Apr 29, 2011 at 2:06 PM, Saler, Jeff <JS...@ball.com> wrote:
> Thanks for the reply. What I want is for the query to search all fields
> for the specified value.
>
> -----Original Message-----
> From: Anuj Kumar [mailto:anujsays@gmail.com]
> Sent: Friday, April 29, 2011 1:51 PM
> To: solr-user@lucene.apache.org
> Subject: Re: querying in Java
>
> Hi Jeff,
>
> In that case, it will query w.r.t default field. What is your default
> search
> field in the schema?
>
> Regards,
> Anuj
>
> On Fri, Apr 29, 2011 at 11:10 PM, Saler, Jeff <JS...@ball.com> wrote:
>
>> Is there any way to query for data that is in any field, i.e. not
> using
>> a specific field name?
>>
>>
>>
>> For example, when I use the following statements:
>>
>>
>>
>> SolrQuery query = new SolrQuery();
>>
>> Query.setQuery("ANALYST:John Schummers");
>>
>> QueryResponse rsp = server.query(query);
>>
>>
>>
>>
>>
>> I get the documents I'm looking for.
>>
>>
>>
>> But I would like to get the same set of documents without using the
>> specific ANALYST field name.
>>
>> I have tried using just "Schummers" as the query, but no documents are
>> returned.
>>
>> The ANALYST field is an indexed field.
>>
>>
>>
>>
>>
>>
>> This message and any enclosures are intended only for the addressee.
>> Please
>> notify the sender by email if you are not the intended recipient. If
> you
>> are
>> not the intended recipient, you may not use, copy, disclose, or
> distribute
>> this
>> message or its contents or enclosures to any other person and any such
>> actions
>> may be unlawful. Ball reserves the right to monitor and review all
>> messages
>> and enclosures sent to or from this email address.
>
>
>
> This message and any enclosures are intended only for the addressee. Please
> notify the sender by email if you are not the intended recipient. If you are
> not the intended recipient, you may not use, copy, disclose, or distribute this
> message or its contents or enclosures to any other person and any such actions
> may be unlawful. Ball reserves the right to monitor and review all messages
> and enclosures sent to or from this email address.
>
RE: querying in Java
Posted by "Saler, Jeff" <JS...@ball.com>.
Thanks for the reply. What I want is for the query to search all fields
for the specified value.
-----Original Message-----
From: Anuj Kumar [mailto:anujsays@gmail.com]
Sent: Friday, April 29, 2011 1:51 PM
To: solr-user@lucene.apache.org
Subject: Re: querying in Java
Hi Jeff,
In that case, it will query w.r.t default field. What is your default
search
field in the schema?
Regards,
Anuj
On Fri, Apr 29, 2011 at 11:10 PM, Saler, Jeff <JS...@ball.com> wrote:
> Is there any way to query for data that is in any field, i.e. not
using
> a specific field name?
>
>
>
> For example, when I use the following statements:
>
>
>
> SolrQuery query = new SolrQuery();
>
> Query.setQuery("ANALYST:John Schummers");
>
> QueryResponse rsp = server.query(query);
>
>
>
>
>
> I get the documents I'm looking for.
>
>
>
> But I would like to get the same set of documents without using the
> specific ANALYST field name.
>
> I have tried using just "Schummers" as the query, but no documents are
> returned.
>
> The ANALYST field is an indexed field.
>
>
>
>
>
>
> This message and any enclosures are intended only for the addressee.
> Please
> notify the sender by email if you are not the intended recipient. If
you
> are
> not the intended recipient, you may not use, copy, disclose, or
distribute
> this
> message or its contents or enclosures to any other person and any such
> actions
> may be unlawful. Ball reserves the right to monitor and review all
> messages
> and enclosures sent to or from this email address.
This message and any enclosures are intended only for the addressee. Please
notify the sender by email if you are not the intended recipient. If you are
not the intended recipient, you may not use, copy, disclose, or distribute this
message or its contents or enclosures to any other person and any such actions
may be unlawful. Ball reserves the right to monitor and review all messages
and enclosures sent to or from this email address.
Re: querying in Java
Posted by Anuj Kumar <an...@gmail.com>.
Hi Jeff,
In that case, it will query w.r.t default field. What is your default search
field in the schema?
Regards,
Anuj
On Fri, Apr 29, 2011 at 11:10 PM, Saler, Jeff <JS...@ball.com> wrote:
> Is there any way to query for data that is in any field, i.e. not using
> a specific field name?
>
>
>
> For example, when I use the following statements:
>
>
>
> SolrQuery query = new SolrQuery();
>
> Query.setQuery("ANALYST:John Schummers");
>
> QueryResponse rsp = server.query(query);
>
>
>
>
>
> I get the documents I'm looking for.
>
>
>
> But I would like to get the same set of documents without using the
> specific ANALYST field name.
>
> I have tried using just "Schummers" as the query, but no documents are
> returned.
>
> The ANALYST field is an indexed field.
>
>
>
>
>
>
> This message and any enclosures are intended only for the addressee.
> Please
> notify the sender by email if you are not the intended recipient. If you
> are
> not the intended recipient, you may not use, copy, disclose, or distribute
> this
> message or its contents or enclosures to any other person and any such
> actions
> may be unlawful. Ball reserves the right to monitor and review all
> messages
> and enclosures sent to or from this email address.