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 Paul Tomblin <pt...@xcski.com> on 2009/08/18 16:32:04 UTC

Can I search for a term in any field or a list of fields?

I've got "<defaultSearchField>text</defaultSearchField>" and so if I
do an unqualified search it only finds in the field text.  If I want
to search title, I can do "title:foo", but what if I want to find if
the search term is in any field, or if it's in "text" or "title" or
"concept" or "keywords"?  I already tried "*:foo", but that throws an
exception:

Caused by: org.apache.solr.client.solrj.SolrServerException:
org.apache.solr.client.solrj.SolrServerException:
org.apache.solr.common.SolrException: undefined field *
     [java] 	at
org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:161)


-- 
http://www.linkedin.com/in/paultomblin

Re: Can I search for a term in any field or a list of fields?

Posted by Toby Cole <to...@semantico.com>.
I would consider using the dismax query handler. This allows you to  
send a list of keywords or phrases along with the fields to search over.
e.g., you could use ?qt=dismax&q=foo&qf=title+text+keywords+concept

More details here: http://wiki.apache.org/solr/DisMaxRequestHandler


On 18 Aug 2009, at 15:56, Paul Tomblin wrote:

> So if I want to make it so that the default search always searches
> three specific fields, I can make another field multi-valued that they
> are all copied into?
>
> On Tue, Aug 18, 2009 at 10:46 AM, Marco Westermann<mw...@intersales.de>  
> wrote:
>> I would say, you should use the copyField tag in the schema. eg:
>>
>> <copyField source="sku" dest="text"/>
>>
>> the text-field has to be difined as multivalued=true. When you now  
>> do an
>> unqualified search, it will search every field, which is copied to  
>> the
>> text-field.
>
>
>
> -- 
> http://www.linkedin.com/in/paultomblin

--

Toby Cole
Software Engineer, Semantico Limited
<to...@semantico.com> <tel:+44 1273 358 238>
Registered in England and Wales no. 03841410, VAT no. GB-744614334.
Registered office Lees House, 21-23 Dyke Road, Brighton BN1 3FE, UK.

Check out all our latest news and thinking on the Discovery blog
http://blogs.semantico.com/discovery-blog/


Re: Passing a Cookie in SolrJ

Posted by Chris Hostetter <ho...@fucit.org>.
: > but I can't see an easy way to be able to pass a cookie with the request.
: > The cookie is needed to be able to get through the SSO layer but will just

Unless i'm remembering wrong, and HttpClient instance will manage cookies 
for you, so why not just document how your users can use an HttpClient 
instance to talk to a server that will set this cookie, and then reuse 
that HttpClient instance in your CommonsHttpSolrServer instance.

: > be ignored by Solr. I see that you are using Apache Commons Http Client and
: > with that I would be able to write the cookie if I had access to the
: > HttpMethod being used (GetMethod or PostMethod). However, I can not find an
: > easy way to get access to this with SolrJ and thought I would ask before

: There's no easy way I think. You can extend CommonsHttpSolrServer and
: override the request method. Copy/paste the code from
: CommonsHttpSolrServer#request and make the changes. It is not an elegant way
: but it will work.

If he really needs to hardcode the cookie value into code, wouldn't it be 
easier to extend HttpClient and modify the methods which take in an 
HttpMethod object to first set the cookie on those obejcts before 
delegating to super?



-Hoss


Re: Passing a Cookie in SolrJ

Posted by Lance Norskog <go...@gmail.com>.
SolrJ uses the Apache Commons HTTP client. This describes the authentication
system:
http://hc.apache.org/httpclient-3.x/authentication.html

<http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/auth/package-frame.html>
*This has code to use authentication*

https://issues.apache.org/jira/browse/SOLR-1238

You might be able to find an openSSO implementation for this. Or hack up a
simple one.

On Wed, Aug 19, 2009 at 5:48 AM, Shalin Shekhar Mangar <
shalinmangar@gmail.com> wrote:

>  On Tue, Aug 18, 2009 at 10:18 PM, Ramirez, Paul M (388J) <
> paul.m.ramirez@jpl.nasa.gov> wrote:
>
> > Hi All,
> >
> > The project I am working on is using Solr and OpenSSO (Sun's single sign
> on
> > service). I need to write some sample code for our users that shows them
> how
> > to query Solr and I would just like to point them to the SolrJ
> documentation
> > but I can't see an easy way to be able to pass a cookie with the request.
> > The cookie is needed to be able to get through the SSO layer but will
> just
> > be ignored by Solr. I see that you are using Apache Commons Http Client
> and
> > with that I would be able to write the cookie if I had access to the
> > HttpMethod being used (GetMethod or PostMethod). However, I can not find
> an
> > easy way to get access to this with SolrJ and thought I would ask before
> > rewriting a simple example using only an ApacheHttpClient without the
> SolJ
> > library. Thanks in advance for any pointers you may have.
> >
>
> There's no easy way I think. You can extend CommonsHttpSolrServer and
> override the request method. Copy/paste the code from
> CommonsHttpSolrServer#request and make the changes. It is not an elegant
> way
> but it will work.
>
> --
> Regards,
> Shalin Shekhar Mangar.
>



-- 
Lance Norskog
goksron@gmail.com

Re: Passing a Cookie in SolrJ

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
On Tue, Aug 18, 2009 at 10:18 PM, Ramirez, Paul M (388J) <
paul.m.ramirez@jpl.nasa.gov> wrote:

> Hi All,
>
> The project I am working on is using Solr and OpenSSO (Sun's single sign on
> service). I need to write some sample code for our users that shows them how
> to query Solr and I would just like to point them to the SolrJ documentation
> but I can't see an easy way to be able to pass a cookie with the request.
> The cookie is needed to be able to get through the SSO layer but will just
> be ignored by Solr. I see that you are using Apache Commons Http Client and
> with that I would be able to write the cookie if I had access to the
> HttpMethod being used (GetMethod or PostMethod). However, I can not find an
> easy way to get access to this with SolrJ and thought I would ask before
> rewriting a simple example using only an ApacheHttpClient without the SolJ
> library. Thanks in advance for any pointers you may have.
>

There's no easy way I think. You can extend CommonsHttpSolrServer and
override the request method. Copy/paste the code from
CommonsHttpSolrServer#request and make the changes. It is not an elegant way
but it will work.

-- 
Regards,
Shalin Shekhar Mangar.

RE: Passing a Cookie in SolrJ

Posted by Fuad Efendi <fu...@efendi.ca>.
> some sample code for our users that shows them how to query Solr

- I believe you don't have to use SolrJ to query Solr; SolrJ can query and
parse XML response from server; if your clients can use raw URL as a query
and raw XML (JSON etc.) as a response - you don't need SolrJ.

To  pass cookie with SolrJ you need modify source code... or may be you can
get access to core HttpClient objects via some configuration (singleton) and
pass default per-client cookie without altering SOLR


-----Original Message-----
From: Ramirez, Paul M (388J) [mailto:paul.m.ramirez@jpl.nasa.gov] 
Sent: August-18-09 12:48 PM
To: solr-user@lucene.apache.org
Subject: Passing a Cookie in SolrJ

Hi All,

The project I am working on is using Solr and OpenSSO (Sun's single sign on
service). I need to write some sample code for our users that shows them how
to query Solr and I would just like to point them to the SolrJ documentation
but I can't see an easy way to be able to pass a cookie with the request.
The cookie is needed to be able to get through the SSO layer but will just
be ignored by Solr. I see that you are using Apache Commons Http Client and
with that I would be able to write the cookie if I had access to the
HttpMethod being used (GetMethod or PostMethod). However, I can not find an
easy way to get access to this with SolrJ and thought I would ask before
rewriting a simple example using only an ApacheHttpClient without the SolJ
library. Thanks in advance for any pointers you may have.

Thanks,
Paul Ramirez



Re: Passing a Cookie in SolrJ

Posted by Chris Hostetter <ho...@fucit.org>.
: Subject: Passing a Cookie in SolrJ
: In-Reply-To: <8e...@mail.gmail.com>

http://people.apache.org/~hossman/#threadhijack
Thread Hijacking on Mailing Lists

When starting a new discussion on a mailing list, please do not reply to 
an existing message, instead start a fresh email.  Even if you change the 
subject line of your email, other mail headers still track which thread 
you replied to and your question is "hidden" in that thread and gets less 
attention.   It makes following discussions in the mailing list archives 
particularly difficult.
See Also:  http://en.wikipedia.org/wiki/Thread_hijacking




-Hoss


Passing a Cookie in SolrJ

Posted by "Ramirez, Paul M (388J)" <pa...@jpl.nasa.gov>.
Hi All,

The project I am working on is using Solr and OpenSSO (Sun's single sign on service). I need to write some sample code for our users that shows them how to query Solr and I would just like to point them to the SolrJ documentation but I can't see an easy way to be able to pass a cookie with the request. The cookie is needed to be able to get through the SSO layer but will just be ignored by Solr. I see that you are using Apache Commons Http Client and with that I would be able to write the cookie if I had access to the HttpMethod being used (GetMethod or PostMethod). However, I can not find an easy way to get access to this with SolrJ and thought I would ask before rewriting a simple example using only an ApacheHttpClient without the SolJ library. Thanks in advance for any pointers you may have.

Thanks,
Paul Ramirez

Re: Can I search for a term in any field or a list of fields?

Posted by Paul Tomblin <pt...@xcski.com>.
On Tue, Aug 18, 2009 at 11:04 AM, Marco Westermann<mw...@intersales.de> wrote:
> exactly! for example you could create a field called "all". And you copy
> your fields to it, which should be searched, when all fields are searched.
>

Awesome, that worked great.  I made my "all" field 'stored="false"
indexed="true"' and I can search for a term that I know is in any of
the key fields and it finds it.

Thanks.


-- 
http://www.linkedin.com/in/paultomblin

Re: Can I search for a term in any field or a list of fields?

Posted by Marco Westermann <mw...@intersales.de>.
exactly! for example you could create a field called "all". And you copy 
your fields to it, which should be searched, when all fields are searched.

then you have two possibilities: either you make this field the 
defaultSearchField for use of unqualified searches. or you qualify the 
field in the query all:foo and all fields are searched which have been 
copied to the all-field.

best
Marco

Paul Tomblin schrieb:
> So if I want to make it so that the default search always searches
> three specific fields, I can make another field multi-valued that they
> are all copied into?
>
> On Tue, Aug 18, 2009 at 10:46 AM, Marco Westermann<mw...@intersales.de> wrote:
>   
>> I would say, you should use the copyField tag in the schema. eg:
>>
>> <copyField source="sku" dest="text"/>
>>
>> the text-field has to be difined as multivalued=true. When you now do an
>> unqualified search, it will search every field, which is copied to the
>> text-field.
>>     
>
>
>
>   


-- 
++ Business-Software aus einer Hand ++
++ Internet, Warenwirtschaft, Linux, Virtualisierung ++
http://www.intersales.de
http://www.eisxen.org
http://www.tarantella-partner.de
http://www.medisales.de
http://www.eisfair.net

interSales AG Internet Commerce
Subbelrather Str. 247
50825 Köln

Tel  02 21 - 27 90 50
Fax  02 21 - 27 90 517
Mail info@intersales.de
Mail mw@intersales.de
Web  www.intersales.de

Handelsregister Köln HR B 30904
Ust.-Id.: DE199672015
Finanzamt Köln-Nord. UstID: nicht vergeben
Aufsichtsratsvorsitzender: Michael Morgenstern
Vorstand: Andrej Radonic, Peter Zander 


Re: Can I search for a term in any field or a list of fields?

Posted by Paul Tomblin <pt...@xcski.com>.
So if I want to make it so that the default search always searches
three specific fields, I can make another field multi-valued that they
are all copied into?

On Tue, Aug 18, 2009 at 10:46 AM, Marco Westermann<mw...@intersales.de> wrote:
> I would say, you should use the copyField tag in the schema. eg:
>
> <copyField source="sku" dest="text"/>
>
> the text-field has to be difined as multivalued=true. When you now do an
> unqualified search, it will search every field, which is copied to the
> text-field.



-- 
http://www.linkedin.com/in/paultomblin

Re: Can I search for a term in any field or a list of fields?

Posted by Marco Westermann <mw...@intersales.de>.
Hi Paul,

I would say, you should use the copyField tag in the schema. eg:

<copyField source="sku" dest="text"/>

the text-field has to be difined as multivalued=true. When you now do an 
unqualified search, it will search every field, which is copied to the 
text-field.

with best regards,

Marco Westermann

Paul Tomblin schrieb:
> I've got "<defaultSearchField>text</defaultSearchField>" and so if I
> do an unqualified search it only finds in the field text.  If I want
> to search title, I can do "title:foo", but what if I want to find if
> the search term is in any field, or if it's in "text" or "title" or
> "concept" or "keywords"?  I already tried "*:foo", but that throws an
> exception:
>
> Caused by: org.apache.solr.client.solrj.SolrServerException:
> org.apache.solr.client.solrj.SolrServerException:
> org.apache.solr.common.SolrException: undefined field *
>      [java] 	at
> org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:161)
>
>
>   


-- 
++ Business-Software aus einer Hand ++
++ Internet, Warenwirtschaft, Linux, Virtualisierung ++
http://www.intersales.de
http://www.eisxen.org
http://www.tarantella-partner.de
http://www.medisales.de
http://www.eisfair.net

interSales AG Internet Commerce
Subbelrather Str. 247
50825 Köln

Tel  02 21 - 27 90 50
Fax  02 21 - 27 90 517
Mail info@intersales.de
Mail mw@intersales.de
Web  www.intersales.de

Handelsregister Köln HR B 30904
Ust.-Id.: DE199672015
Finanzamt Köln-Nord. UstID: nicht vergeben
Aufsichtsratsvorsitzender: Michael Morgenstern
Vorstand: Andrej Radonic, Peter Zander