How to change default value of Facet.limit in Solr - solr

I have reviewed Solr this document here. As per this document Solr returns 100 records for facets. What if I want fetch more records. How can I change default value for facet records?
I do not want to get it through Solr query. Is there any way to change its default value?

In your requestHandler name="/select" you can set the any value you want. If you are using some other requestHandler then set it in the respective requestHandler as per your needs.
<lst name="defaults">
....
<str name="facet.limit">1000</str>
....
</lst>

Related

Is it possible to have default filter values in Apache Solr?

Is it possible to tell Solr to use a specific filter value if no other filter is defined for that field?
Example:
If there is no other fq entry present for a field age then search by default for age > 18.
Yes, you can add these to the requestHandler definition:
<lst name="defaults">
<str name="fq">age:[18 TO *]</str>
</lst>
(or if you really meant larger than 18 and not 18 or older, {18 TO *] or [19 TO *]).
You can also use appends and invariants instead of defaults to add a filter query to all queries or set a parameter to a static value that an URL parameter can't override.

Getting only 10 rows in Solr Cassandra search

I am working on Datastax Cassandra with Apache Solr for multiple partial search.
Issue is, everytime I am getting only 10 rows even once I am doing count(*) query, I am able to check there are 1300 rows belong to particular query.
nandan#cqlsh:testo> select id from empo where solr_query = 'isd:9*';
id
--------------------------------------
5ee5fca6-6f48-11e6-8b77-86f30ca893d3
27e3e3bc-6f48-11e6-8b77-86f30ca893d3
f3156e76-6f47-11e6-8b77-86f30ca893d3
f315ac74-6f47-11e6-8b77-86f30ca893d3
f315bc82-6f47-11e6-8b77-86f30ca893d3
27e3058c-6f48-11e6-8b77-86f30ca893d3
4016eee4-6f47-11e6-8b77-86f30ca893d3
1bd33e34-6f47-11e6-8b77-86f30ca893d3
8f0a9168-6f47-11e6-8b77-86f30ca893d3
6669cc42-6f47-11e6-8b77-86f30ca893d3
(10 rows)
After searching few links, I make changes into solrconfig.xml file. and changes are as below.
<requestHandler class="solr.SearchHandler" default="true" name="search">
<!-- default values for query parameters can be specified, these
will be overridden by parameters in the request
-->
<lst name="defaults">
<int name="rows">1000000</int>
</lst>
<!-- SearchHandler for CQL Solr queries:
this handler doesn't support any additional components, only default parameters
-->
<requestHandler class="com.datastax.bdp.search.solr.handler.component.CqlSearchHandler" name="solr_query">
<lst name="defaults">
<int name="rows">1000000</int>
</lst>
</requestHandler>
But still I am getting same issue. Please let me know what will be the solution for this.
Thanks.
I don't think it should be managed from the schema. The query has a rows and a start parameter. Use those: rows defines the max number of items to return, start defines the first item in the list to return:
q=isd:9*&rows=22&start=17&wt=json
isd:9* returns all items where isd starts with 9.
start=17 says begin at the 18th item in the list.
rows=22 returns 22 items, from 18 to 40.
try this
select id from empo where solr_query = 'isd:9*' limit 1300;
this will give you all 1300 rows, by default solr limits the rows it return to 10.

Storing filter definition on Solr server

I have a situation where all my queries have some sub filter queries which are added each time and are very long.
The query filters are the same each time so it is a waste of time sending them over and over to Solr server and parsing them on the other side just to find them in the cache.
Is there a way I can send filter query definition once to the Solr server and then reference it in following queries?
You can add a static configuration directive in your solr config (solrconfig.xml):
<requestHandler name="/select" class="solr.SearchHandler">
<lst name="appends">
<str name="fq">foo:value</str>
</lst>
</requestHandler>
.. this will always append a fq= term to the query string before the SearchHandler receives the query. Other options are invariants or defaults. See Request Handlers and Search Handlers on the community wiki for more information.

Best way to search dynamic list of fields using Solr?

We are implementing a search function using Solr as the backend engine. The data is extracted from the database using DIH. Key information of the document including:
- product number (number)
- product name (name)
- applicant name (applicant)
- product purpose (purpose)
All fields are stored and indexed.
We provide a single search box for the users to type any number of keywords and the system will search across all fields and try to match all of them. To do that, we create additional field that combine all information above using "copyField".
However, another requirement is that the user would be able to limit their search in selected target fields. For example, the user could select only name and purpose fields. In this case, the keywords search will only search from these two fields.
Currently, we use the following query approach to achieve the function:
For example, given that
- the user provide keywords: K1 and K2,
- and the user want to search on name, applicant and purpose only,
the following search string will be dynamically generated and sent to Solr:
(name:K1 OR applicant:K1 OR purpose:K1) AND (name:K2 OR applicant:K2 OR purpose:K2)
Are there any other way to implement the function? It would be much appreciated if you could share your expertise.
Thanks,
Fan
you can check for Request handler with edismax and with default configuration qf which would search on the copyfield which holds data from all the fields.
qf query field on which the query would be executed.
You would just need to pass a single param to solr qt=edismax&q=K1 K2 for search.
<requestHandler name="edismax" class="solr.SearchHandler" >
<lst name="defaults">
<str name="defType">edismax</str>
<str name="qf">
all_fields
</str>
<str name="fl">
*,score
</str>
<str name="q.alt">*:*</str>
</lst>
</requestHandler>
If the user wants to search on name or purpose, i would suggest just passing the fields and the query to this request handler.
The parameters passed would override the default parameters.
You would just need to pass a single param to solr qt=edismax&q=K1 K2&qf=name applicant for search.
You can control the OR behaviour using the mm (minimum match) parameter.

Limiting / Filtering multivalue fields in Solr

Is there a way to limit, or filter, the returned text of a multivalued field in Solr? Given the following document structure in Solr:
...
<doc>
<str name="title">example</str>
<arr name="foo">
<str>bar1</str>
<str>bar2</str>
<str>bar3</str>
<str>bar4</str>
<str>bar5</str>
<str>bar6</str>
</arr>
</doc>
...
I'd like to limit the response to only show 1 of the "foo" values based on a Filter Query request. So for example, the query:
select/?q=example&fq=foo:bar2`
I would want a response of:
...
<doc>
<str name="title">example</str>
<arr name="foo">
<str>bar2</str>
</arr>
</doc>
...
Nope. There is not way to filter the Multivalued Values returned with the response.
You can easily do it at client side though.
If you can use Facet to get the list, you can use facet.prefix to limit the values for the field foo returned as facet.
Did you try using dynamic fields if you know the sample space of values for 'foo'? For example:
and then filter on bar_x:true. You would end up using a large number of dynamic fields.
filter query should work, try below code
&fq=+foo:"bar2"

Resources