General Search Query in Solr - solr

I have tried to run a single term search in Solr 9.0 through by using
q=term
(e.g. http://localhost:8983/solr/windowstest/select?indent=true&q.op=OR&q=yelp).
I've noticed that older versions of Solr were able to handle such a request but now I can only search all fields for that term by adding using OR
q=id:yelp OR subject:yelp OR body:yelp
(e.g. http://localhost:8983/solr/windowstest/select?indent=true&q.op=OR&q=id%3Ayelp%20OR%20subject%3Ayelp%20OR%20body%3Ayelp).
Is there a way to not have to indicate the fields?

There is no setting for "searching all fields"; however, what is usually done is to have a single field as the copyField destination for all fields. You can do this by defining a catch-all field (by default named _text_, and then configuring <copyField src="*" dest="_text_"> - making the content of all the fields get copied into _text_.
You can then set the default search field (i.e. where there isn't a field name given) with the df parameter in the query - the default field.
http://localhost:8983/solr/windowstest/selectq.op=OR&q=yelp&df=_text_
If you want to set this as the default, you configure it as a default parameter in solrconfig.xml under the specific request handler:
<requestHandler name="/select" class="solr.SearchHandler">
<lst name="defaults">
<str name="df">_text_</str>
<int name="rows">10</int>
</lst>
</requestHandler>
.. or by using initparams:
<initParams path="/update/**,/query,/select,/tvrh,/elevate,/spell">
<lst name="defaults">
<str name="df">_text_</str>
</lst>
</initParams>

Related

where to set default solr query parameters for all requests

I am still new to Solr. I am trying to find a place where I can put default query parameters.
I know I can set default query parameters in places such as
<requestHandler name="/select" class="solr.SearchHandler">
,
<requestHandler name="/query" class="solr.SearchHandler">
, and
<requestHandler name="/browse" class="solr.SearchHandler">.
But what I really want is to set default query parameters for all the above three (or more) sections.
Example default parameters:
<str name="defType">edismax</str>
<str name="qf">
id^2.5
name^2
</str>
Where should I place the above lines in `solrconfig.xml'
In the latest Solr, you would use initParams section for that. The examples shipped with Solr demonstrate it.

Solr edismax qf and pf defaults not working to boost fields

I am attempting to set up a request handler that will boost certain fields by different amounts. I have the following request handler.
<requestHandler name="/select" class="solr.SearchHandler" default="true">
<lst name="defaults">
<str name="echoParams">explicit</str>
<str name="start">0</str>
<int name="rows">10</int>
<str name="defType">edismax</str>
<str name="qf">
title^50.0 searchTitle^7.0 keywords^5.0 content^1.0 text^1.0
</str>
<str name="pf">
title^50.0 searchTitle^7.0 keywords^5.0 content^1.0 text^1.0
</str>
<str name="df">text</str>
</lst>
</requestHandler>
However, the fields aren't being boosted correctly, if at all. I noticed that documents with the search term in the title field aren't appearing any higher than documents with the search term in the text field. Arbitrarily re-arranging the weights produces the same document order each time.
When I go into the solr web interface/admin UI and do a search I get the same results. However, if I explicitly check the edismax checkbox and enter the field-boost data in the qf and pf boxes I get the results and the weighting I would expect.
In fact, I also just tried changing the rows value to 5 and still received the same result. It looks like my queries aren't being handled by the /select handler, even though that is what I choose both in the solr Admin UI and when I create the HttpSolrServer object to do the queries from the server.
I am using solr v4.8.0.
Any help would be appreciated.
Check setting in solrconfig for
<requestDispatcher handleSelect="false" >
If you want to use select as a requesthandler, this needs to be
<requestDispatcher handleSelect="true" >

Indexing issue in Nutch-Solr (Want to display data in solr)

I am trying to crawl data using Nutch and Index that Data in Solr.
I have follow the steps from this Url Using Nutch with Solr and Nutch Wiki Tutorial
I've successfully Index data using Solrindex command
bin/nutch solrindex http://127.0.0.1:8983/solr/ crawl/crawldb -linkdb crawl/linkdb crawl/segments/* but in Result I can't find the Indexed data.
I want result as below Image
But I can't see any result data at right side.
If you want some data to be returned with the search response, check that the targeted fields are stored by solr, then you can set a list of fields to return in your query using fl param (with stored field name as value). You can also set default fl values in solrconfig.xml.
For example, let's say you want content field to be returned. In your schema.xml, in the <fields> declaration you should have the option stored="true" for this field like so :
<field name="content" type="text" indexed="true" stored="true"/>
Then in solrconfig.xml, declare default fl params in the requestHandler definition, you can set specific fields (space separated field names). The xml sample (grabbed from the tutorial) should look like this if we just want data stored in the content field to be returned.
<requestHandler name="/nutch" class="solr.SearchHandler" >
<lst name="defaults">
<str name="defType">dismax</str>
<str name="echoParams">explicit</str>
<float name="tie">0.01</float>
<str name="qf">
content^0.5 anchor^1.0 title^1.2
</str>
<str name="pf">
content^0.5 anchor^1.5 title^1.2 site^1.5
</str>
<str name="fl">
url content
</str>
<str name="mm">
2<-1 5<-2 6<90%
</str>
<int name="ps">100</int>
<bool hl="true"/>
<str name="q.alt">*:*</str>
<str name="hl.fl">title url content</str>
<str name="f.title.hl.fragsize">0</str>
<str name="f.title.hl.alternateField">title</str>
<str name="f.url.hl.fragsize">0</str>
<str name="f.url.hl.alternateField">url</str>
<str name="f.content.hl.fragmenter">regex</str>
</lst>
</requestHandler>
You can override these defaults right in the query. A common use case is to put "*,score" in the fl area in solr query interface so that you can see all stored fields (using wildcard character *) along with the score in the results. You might also want to specify the query type parameter (qt) according to the targeted request handler (should be "/nutch").
Helpful links :
http://wiki.apache.org/solr/SchemaXml#Common_field_options
http://wiki.apache.org/solr/CommonQueryParameters#fl

Is it possible to filter Solr results using solrconfig.xml?

I have a set of documents in Solr which I search through two different requestHandlers. One requestHandler is used internally and should be able to see all documents. The other is used by a public-facing search engine.
Is there a way I can apply an fq parameter in my requestHandler definition, so that a subset of the documents won't be returned?
In this instance I only want to return documents where the "fivi" field is NOT ZERO.
The request handler wiki page shows how to specify default values:
<requestHandler name="/foo" class="my.package.CustomRequestHandler" />
<!-- initialization args may optionally be defined here -->
<lst name="defaults">
<int name="rows">10</int>
<str name="fl">*</str>
<str name="version">2.1</str>
</lst>
</requestHandler>
But if you don't want them to be able to override the values then use invariants instead of defaults for the name of the lst element.

Solr4 currently only looks at the default "df" field, how can we search multiple fields?

In Solr 4, I see that we've configured the default field "df" in the /select request handler:
<requestHandler name="/select" class="solr.SearchHandler">
<!-- default values for query parameters can be specified, these
will be overridden by parameters in the request
-->
<lst name="defaults">
<str name="echoParams">explicit</str>
<int name="rows">10</int>
<str name="df">id</str>
But id is our unique document field, so all queries are defaulting to "id:my_query", which always returns 0 results.
How do I define which fields should be queried by default?
This is an upgrade from v3 to v4 and this part of it seems to have been broken along the way.
You can use a copy field named "text", copy all your searchable fields into this field and specify it as default search field.
<requestHandler name="/select" class="solr.SearchHandler">
<!-- default values for query parameters can be specified, these
will be overridden by parameters in the request
-->
<lst name="defaults">
<str name="echoParams">explicit</str>
<int name="rows">10</int>
<str name="df">text</str>
You can add fields to be copied to a copy field as follows:
<copyField source="field1" dest="text"/>
<copyField source="field2" dest="text"/>
...
<copyField source="fieldn" dest="text"/>
Note that "text" is the copy field here.
you can use edismax search.
See https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+Query+Parser
Check the qf(query field) parameter. You can pass multiple fields to it

Resources