Is there a way to exclude fields in Solr? - solr

What is the fl parameter I have to use to get all fields in a document except for "field1" in Solr?

Right now is not possible to define, in the fl parameter, the fields to exclude from the results. You have to define all the fields you want and not put field1 in the list. Another possibility is using the regex syntax, as you can see from the official documentation: https://solr.apache.org/guide/solr/latest/query-guide/common-query-parameters.html#fl-field-list-parameter
A different solution can be to not store the field in Solr, this possibility clearly depends on your field usage.

Related

Hybris: Combine different solr facet under one

I have applied solr facet on properties of products.
Eg: The product can be either Medicine(0/1) or Drug(0/1) or Poison(0/1).
0 means NO, 1 means YES.
These are different features of a product hence appear as different facets. It is possible to display them under one facet instead eg: "Type", under which these three solr facet "Medicine", "Drug", "Poison" should display like:
Type
-----
Medicine (50)
Drug (100)
Poison (75)
Not sure about Hybris, but you should be able to do so with facet queries. You would have one facet query per each of your three conditions. In the UI, you can organize the counts anyway you want.
However, I am not sure why you can't just have a category field that contains a multi-valued field that contains Medicine and/or Drug and/or Poison value. Then faceting on that field would give you the breakdowns. If your values do not come in that way, you can probably manipulate them either with copyField or with a custom Update Request Processor chain to merge into one field.
This is super easy. Just make an IndexedProperty "Type" and a new custom ValueProvider for it. Then extract these values based on the boolean flags - just hard code if necessary. No need for anything more complex.
I tried the solutions posted here but they were not fitting my requirement. I did changes through facet navigation tag files to bring all classification attribute facets (Medicine, Drug, Poison) under a single facet (Type).

How does Solr process the query string when using edismax qf parameter and specify field in query

All:
[UPDATE]
After reading the debug explain, it seems that the qf will expand only
the keywords without specifying field.
===================================================================
When I learn to use edismax query parser, it said the qf paramter is:
Query Fields: specifies the fields in the index on which to perform
the query. If absent, defaults to df.
And its purpose is to generate all fields' combination with the query terms.
However, if we already specify the field in query( q prameter), I wonder what happen when I specify another different fields in qf?
For example:
q=title:epic
defType=edismax
qf=content
Could anyone give some explanation how SOLR interpret this query?
Thanks
When you specify qf it means you want solr to search for whatever is in the "q" field in these "qf" fields. So, your first and third line contradict each other:
q=title:epic
defType=edismax
qf=content
If you want to search for any document where the content field contains anything matching your search terms, but these search terms as tokens in "q" separated by +OR+.
like this...
q=I+OR+like+OR+books+ORand+OR+games
defType=edismax
qf=content
When q=title:epic. It means you has settled the query field to title, so the qf parameter could not be set as "content", in this case, you have no query result for sure. You leave the qf parameter empty or set it as "title"

Why does Dismax not work in simple query?

All:
I am pretty new to SOLR, I upload some documents which have "season" in content field(store but not indexed, copy to text field) and in title field(store and indexed copy to text field)
When I use basic query without dismax like:
http://localhost:8983/solr/collection1/select?q=season&rows=5&wt=json&indent=true
It works very well and return correct results, but when I want to boost those documents which have more "season" in content rather than title, I used dismax like(I guess the way I use it is totally, cos the content is not indexed, but I at least expect certain return result even incorrect ):
http://localhost:8983/solr/collection1/select?q=season&rows=5&wt=json&indent=true&defType=dismax&qf=content%5E100+title%5E1
There is no match result returned, I wonder if anyone could help me with this? Or could anyone show me how to use dismax correctly
Thanks
In your second query you specify the "content" field as the one and only query field but earlier you write that this field is stored but not indexed. If a field is not indexed you can not search against it.
I faced the same problem. Tracked it down to the schema definition where for dismax to work, field type should be text and not string
for e.g text_general,text_en_splitting,text_en
Its because of the tokenizers used for this field types.
-->

Can I use Solr term component with filtering on non-term fields

http://localhost:8080/search/terms?terms.prefix=ab&terms.fl=text&terms.sort=count
I have the above terms query which works as I expect. Returns all the terms from the "text" field that have a certain prefix, sorted by count.
I want to return only the terms where another field "language" is "en" can I add such a filter to a terms query?
Unfortunately you can't filter while accessing the indexed terms within a field through the TermsComponent. That's one of the limitations you face when you make auto suggestions for example. If you're making auto-suggestions, one of the ways that supports filtering is based on a facet and the prefix parameter like explained here.

what is the advantages of mutivalued option in solr

What is the advantages of mutivalued field option in solr.
I have a field with comma separated keywords.
I can do 2 things
make a non-multivalued text field
make a multivalued text field which contains each keyword
I can still query in both the cases. So whats the advantages of multivalued over non-multivalued?
advantages of multivalued: you don't need to change the document design. If en document containes multiple values in one filed, so solr/lucen can handle this field.
Also an advantage: multiple values could describe an document more exact (thing about tags of an blog post, or so)
advantages of non-multivalued: you can use specific features, which required an single term (word) in one filed, like spell checking. It's also a benefit for clustering (carrot) or grouping, which works mostly better on non-multivalued fields
Querying by the multivalue field will receive what you want.
Example: doc1 has a keyword 'abc', and doc2 has a keyword 'abcd'. If query by keyword 'abc' only doc1 should be matched.
So in non-multivalue approach both documents will matched, case you'll use like syntax.
multivalue fields can be very handy, let say you have many fields and you wish to search for several fields but not in all of them. you can create multivalue field that include all the fields that you wont to search for them on this field and search in it.
for example, let say you have fields that may have value of string or value of number. and than you wish to search on all string values that were found in the document. so you can create multivalue field for all string values and search in it.

Resources