How to find a SOLR entry that has a field with no value? - solr

I have a local SOLR server with some entries that have a field "debaTest": "" while some entries don't have this field at all.
Is there a way in Solr to filter out the entries that have this field? the value for the field will always be null or empty.
Please note: Something in the lines of q=-debaTest:[* TO *] or
-debaTest:* won't work for my requirement as this returns the entries that don't have these fields at all and I want the entries that have this field but without a value.

Related

Facet for Empty or null values for any field in Solr

I am using Facet in my solr implemententation. Facets are display for all the keywords of fields having concrete values.
Facets are not displayed for the empty values. I want to show a facets for empty values as well.
For example, in below example data facet is displayed for the value in Country field as
Sample Data for Solr fields
US (6)
CA (5)
IND (5)
I also want to show facet as
[Empty] (7)
Please suggest some workaround to get Facet for empty values.
You can use facet.missing to get a count for the number of documents that doesn't have a value in the field.
The facet.missing Parameter
If set to true, this parameter indicates that, in addition to the Term-based constraints of a facet field, a count of all results that match the query but which have no facet value for the field should be computed and returned in the response.
The default value is false.
This parameter can be specified on a per-field basis with the syntax of f.<fieldname>.facet.missing.

Is there ever a reason for copying fields in to a facet field in the index?

I'm looking at a very old solr instance (4-6 years since last touched), and I am seeing these extra dynamic fields, 'f_' and 'fs_' for multi and single valued facet fields.
My understanding, though, is that facets only happen in query-time.
Also, it's just a copy over - the fields dont change type.
So before I nuke these fields to kingdom come; is there a reason for facet fields in an index that is just a copied field?
Thanks
Facets only happening query time is a bit of a misnomer - the content (the tokens) that the facet represents from is generated when indexing. The facet gives the distinct number of documents that has a specific token present.
That means that if the field type is identical and there is only one field being copied into the other named field, the behaviour between the source and the destination field should be identical.
However, if there are multiple fields copying content into the same field, the results will differ. Also be aware that the type is given from the schema for the field, it's not changed by the copyField instruction in any way. A copy field operation happens before any content runs through the indexing chain for the field.
Usually you want facets to be generated on string fields so that the indexed values are kept as-is, while you want to use a text field or similar for searching (with tokenization), since a string field would only give exact (including matching case) hits.

SoLR - How to filter out records which do not have the field value for field listed in SORT?

In SoLR, We can set sortMissingLast=true on a field in the schema. If the SORT is on this field, it will to push the results which have missing field values to the end.
Is there a way to filter out the results whose sort field values are missing? Please advise.
If you want to restrict your query to documents that only have a certain field set, add the following parameter to your query:
sort_field_name:[* TO *]
This will limit the query to only those documents where the sort field exists.

to get the count of multi valued field in solr

In solr i have a multiValued field called animal and it has the values {cat,dog} is it possible to get the number of values inside the multiValued field in solr(in my example 2)?
If you want to count the items in a multivalued field use CountFieldValuesUpdateProcessorFactory
There is no direct way to get the count of items in a multivalued field.
You can always maintain the field count during indexing and use it.
If not using during query time, you can always count the list size.

Solr multivalued field searchs only the first 2000 values why?

I have a single document with a multivalued field that stores text(say tag). Each entry size is an average 20 characters . This multivalued field can have a huge number of entries. In my case around 3000. Where i query on this field it searches only the first 2000 entries. If i query for anything more than the 2000th entry no results are found why is is? Even though these values are stored and returned when a search within 2000 is done.
I got to the number 2000 by looking at the search results are querying until i got no results.
I am doing a very simple query on that field. Any ideas?

Resources