I was wondering how I can enable faceting in the solr config without being forced to put it all the times in the URL. Secondly how can set the number of fields?
thanks
You can pass all the default parameters you need to your request handler like this:
<requestHandler name="standard" class="solr.SearchHandler" default="true">
<lst name="defaults">
<str name="facet">true</str>
<str name="facet.field">field1</str>
<str name="facet.field">field2</str>
<str name="facet.field">field3</str>
</lst>
</requestHandler>
This way you have facet enabled by default for field1, field2 and field3.
Related
I've followed this to set up shard in Solr. As per this topic "Testing Index Sharding on Two Local Servers", I was able to query into shard and get the result (somehose:port1/solr/select?shards=somehost:port1/solr,somehost:port2/solr&indent=true&q=helloworld
).
In that page it is also mentioned that "Rather than require users to include the shards parameter explicitly, it is usually preferred to configure this parameter as a default in the RequestHandler section of solrconfig.xml."
So, I made the changes in solrconfig.xml of the solr instance which is running on port1
<requestHandler name="/select" class="solr.SearchHandler">
<lst name="defaults">
<str name="echoParams">explicit</str>
<int name="rows">10</int>
<str name="df">text</str>
</lst>
<lst name="shards.info">
<lst name="localhost:port2/solr">
<long name="numFound">1333</long>
<float name="maxScore">1.0</float>
<str name="shardAddress">http://localhost:port2/solr</str>
<long name="time">686</long>
</lst>
<lst name="localhost:port1/solr">
<long name="numFound">342</long>
<float name="maxScore">1.0</float>
<str name="shardAddress">http://localhost:port1/solr</str>
<long name="time">602</long>
</lst>
</lst>
Now, I'm trying to hit somehost:port1/solr/collection1/select?q=helloworld&wt=json&indent=true
but I'm not getting the desired responce. Please let me know what I'm missing here?
You can't just copy the content from the response into your configuration file - those two formats are completely different. The reference is to the fact that each entry in the defaults section is added to the query string (unless they're provided there already - there are also options if you want to force a certain value that can't be overridden).
<requestHandler name="/selectdistributed" class="solr.SearchHandler">
<lst name="defaults">
[...]
<str name="shards">somehost:port1/solr,somehost:port2/solr</str>
</lst>
</requestHandler>
.. should do what you want. This will add shards=somehost:port1/solr,somehost:port2/solr to the query string of all the requsts that go through that handler.
The following query works well for me
http://[]:8983/solr/vault/select?q=VersionComments%3AWhite
returns all the documents where version comments includes White
I try to omit the field name and put it as a default value as follows :
In solr config I write
<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">PackageName</str>
<str name="df">Tag</str>
<str name="df">VersionComments</str>
<str name="df">VersionTag</str>
<str name="df">Description</str>
<str name="df">SKU</str>
<str name="df">SKUDesc</str>
</lst>
I restart the solr and create a full import.
Then I try using
http://[]:8983/solr/vault/select?q=White
(Where
http://[]:8983/solr/vault/select?q=VersionComments%3AWhite
still works)
But I dont get the document any as answer.
What am I doing wrong?
As far as I know you should only have the <str name="df"></str> declared once in your requestHandler
Typically what I do is copy all the fields that i want to search into a default search field called text.
schema.xml:
<copyField source="name_t" dest="text"/>
solrconfig.xml
<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="q">*:*</str>
<str name="echoParams">explicit</str>
<int name="rows">10</int>
<str name="df">text</str>
</lst>
</requestHandler>
If this is not good enough, you can always search other fields using a dismax search with the qf declaration like so:
http://localhost:8983/solr/vault/select/?q= White&defType=dismax&qf=PackageName+Tag+VersionComments+VersionTag+Description+SKU+SKUDesc
It appears that the fq seems to be not working for dismax. I am using solr 2.2
my query is http//mysolrserver:8983/solr/fd=modelid=810 ...
My solr config is default and I get the values if I set q=modelId:810 and not fq=modelId:810
Any ideas ?, Is there any filter in solrconfig that stops fq ?
If you wanna appy filter query over all docs in your index, here is syntax for that:
http//mysolrserver:8983/solr/select?q=*:*&fq=modelid:810
or in your solrconfig.xml, you can specify your own request handler, with q.alt set to :
<requestHandler name="/custom" class="solr.SearchHandler">
<lst name="defaults">
<str name="echoParams">explicit</str>
<str name="defType">dismax</str>
<str name="qf">
title^5.0 description^1.0 keywords^3.0
</str>
<str name="q.alt">*:*</str>
<str name="rows">10</str>
<str name="fl">*,score</str>
</lst>
</requestHandler>
and then your query will be:
http//mysolrserver:8983/solr/custom?fq=modelid:810
I use spellcheck component and when I request solr I have results. But if I use spellcheck.q, i haven't result.
Someone has an idea ?
Thanks
<!-- The spell check component can return a list of alternative spelling
suggestions. -->
<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
<str name="queryAnalyzerFieldType">textSpell</str>
<lst name="spellchecker">
<str name="name">default</str>
<str name="field">spellCheck</str>
<str name="spellcheckIndexDir">./spellchecker</str>
<str name="buildOnCommit">true</str>
<str name="accuracy">0.4</str>
<float name="thresholdTokenFrequency">.0004</float>
</lst>
</searchComponent>
<!--<queryConverter name="queryConverter" class="solr.SpellingQueryConverter"/>-->
<!-- Handler par défaut -->
<requestHandler name="default" class="solr.SearchHandler" lazy="true" default="true">
<lst name="defaults">
<str name="spellcheck.onlyMorePopular">false</str>
<str name="spellcheck.extendedResults">false</str>
<str name="spellcheck.count">10</str>
<str name="hl.usePhraseHighLighter">true</str>
<str name="hl.highlightMultiTerm">true</str>
<str name="hl.mergeContiguous">true</str>
</lst>
<arr name="last-components">
<str>highlight</str>
<str>spellcheck</str>
</arr>
</requestHandler>
Have you added your spellcheck component to the corresponding request handler (in solr config), set spellcheck parameter to true (or on) and configured the correct dictionary to use (if its name different than "default")?
If you don't use the spellcheck.q parameter, then the default is to use the q parameter (from http://wiki.apache.org/solr/SpellCheckComponent#q_OR_spellcheck.q). From that wiki:
Essentially, if you have a spelling "ready" version in your application, then it is probably better to send spellcheck.q, otherwise, if you just want Solr to do the job, use the q parameter
The reason that it works if you change the definition of the field type is probably due to the new field type being "spelling ready". It would help if you posted the query you are using and the relevant lines in the schema.xml.
I have a fieldType named double_score. The values here are all precomputed and can fit in a double format. I would like to use this score to boost the associated values s.t. solr returns values by this order. Moreover, I'd like to do this from just the schema. This last clause seems to be the one that is tripping up my searching / configuring fu.
Thanks.
EDIT: (dismax)
<requestHandler name="default" class="solr.SearchHandler" default="true">
<lst name="defaults">
<str name="defType">dismax</str>
<str name="echoParams">explicit</str>
<int name="rows">10</int>
<str name="qf">name</str>
<str name="bq">double_score</str>
<str name="debug">true</str>
<str name="q.alt">*:*</str>
</lst>
</requestHandler>
Use sort order if you would like your results to be sorted acording to your double_score field.
You can see here how to use sort after your field: http://wiki.apache.org/solr/CommonQueryParameters#sort
If you want this to be set in your schema you just have to add the sort:double_score as a default parameter for each request:
<requestHandler name="default" class="solr.StandardRequestHandler" default="true">
<lst name="defaults">
<str name="sort">double_score</str>
</lst>
</requestHandler>
"returns values by this order" if that means a simple sort, go with Dorin's answer.
But to boost results based on fields (you may take several fields into consideration) , see this: http://wiki.apache.org/solr/SolrRelevancyFAQ#How_can_I_make_.22superman.22_in_the_title_field_score_higher_than_in_the_subject_field