Why Solr Group get only one group,but Solr Facet get only two groups? - solr

Solr:I have a field, the field type is string, the field content is '22 33', when I do Group, why do I get a group? But Facet has two groups
config:
<field name="unit_co" type="text_general" indexed="true" stored="true"/>
group result:
{{
"groupValue":"22",
"doclist":{"numFound":1,"start":0,"docs":\[
{
"unit_co":" 22 33 "}
}}]}}}
facet result:
{
"unit_co":[
"22",1,
"33",1]
}
I tried to solve this problem with other solutions, such as multi-value fields, but Solr does not support groups with multi-value fields.
solr error:can not use FieldCache on multivalued field

Related

Solr 8.6 - combine facets on multivalued dateRange field with exclude tags, negate and OR clause

On Solr 8.6, I have a multivalued field of dateRange type which contains an availability table.
<field name="availabilities" docValues="false" type="dateRange" multiValued="true" indexed="true" required="false" stored="true"/>
"availabilities": [
"[2021-12-22T00:00:00Z TO 2022-01-02T23:59:59Z]",
"[2022-01-20T00:00:00Z TO 2022-02-02T23:59:59Z]",
"[2022-02-10T00:00:00Z TO 2022-02-21T23:59:59Z]"
]
With a facet, I want to be able to select the available and/or unavailable people.
The Solr query is as follows and works well.
http://localhost:8985/solr/rby/select?facet=on&facet.query={!key="FQ4#Available now" ex=tag_availabilities}availabilities:[NOW TO NOW]&fl=id,availabilities&fq={!tag=tag_availabilities}availabilities:([NOW TO NOW])&q=*:*&rows=10&wt=json
For the unavailable people query, it does not work when I exclude NOW with {} like this.
http://localhost:8985/solr/rby/select?facet=on&facet.query={!key="FQ4#Unavailable" ex=tag_availabilities}availabilities:{NOW TO NOW}&fl=id,availabilities&fq={!tag=tag_availabilities}availabilities:({NOW TO NOW})&q=*:*&rows=10&wt=json
Solr answers with the following error:
"msg": "Wrong order: 2021-12-30T16:18:06.304 TO 2021-12-30T16:18:06.302",
I found a workaround with - before field but now I can't combine the two filters of the facet with an OR.
http://localhost:8985/solr/rby/select?facet=on&facet.query={!key="FQ4#Unavailable" ex=tag_availabilities}-availabilities:[NOW TO NOW]&fl=id,availabilities&fq={!tag=tag_availabilities}-availabilities:([NOW TO NOW])&q=*:*&rows=1000&wt=json
Thanks for your help

How to execute date range query on date index - SOLR

What is the correct way to run the range queries on SOLR date index field. Below is the snapshot from schema.xml file for the field definition:
<dynamicField name="ds_*" type="pdate" indexed="true" stored="false" multiValued="false" docValues="true"/>
Context: The SOLR document contains a date element and value as "ds_clip_date":"2020-10-14T12:00:00Z".
Requirement is to allow user to fetch documents from this month/last 30 days/last 90 days/this year.
I tried building below from SOLR query dashboard - but this gives me all the documents without respecting the range:
http://localhost:8983/solr/testcore/select?facet.field=ds_clip_date&facet.query=facet.range%3Dds_clip_date%26f.ds_clip_date.facet.range.start%3D2020-11-17&facet=on&fl=ds_clip_date&q=*%3A*&rows=200&start=0
and I get the below summary:
"facet_counts":{
"facet_queries":{
"facet.range=ds_clip_date&f.ds_clip_date.facet.range.start=2020-11-17":0},
"facet_fields":{
"ds_clip_date":[
"2020-12-15T12:00:00Z",20,
"2020-12-16T12:00:00Z",14,
"2020-09-25T12:00:00Z",1,
"2020-10-14T12:00:00Z",1,
"2020-10-20T12:00:00Z",1,
"2020-10-22T12:00:00Z",1,
"2020-11-24T12:00:00Z",1,
"2020-12-17T12:00:00Z",1]},
"facet_ranges":{},
"facet_intervals":{},
"facet_heatmaps":{}}
Also, referring to some other QA, tried to build as below:
http://localhost:8983/solr/testcore/select?facet=true&facet.field=ds_clip_date&facet.range=ds_clip_date&f.ds_clip_date.facet.range.start=2020-12-15T00:00:00Z&f.ds_clip_date.facet.range.end=NOW&f.ds_clip_date.facet.range.gap=%2B1DAY
The result is as below:
{
"response":{"numFound":0,"start":0,"numFoundExact":true,"docs":[]
},
"facet_counts":{
"facet_queries":{},
"facet_fields":{
"ds_clip_date":[]},
"facet_ranges":{
"ds_clip_date":{
"counts":[
"2020-12-15T00:00:00Z",0,
"2020-12-16T00:00:00Z",0,
"2020-12-17T00:00:00Z",0],
"gap":"+1DAY",
"start":"2020-12-15T00:00:00Z",
"end":"2020-12-18T00:00:00Z"}},
"facet_intervals":{},
"facet_heatmaps":{}}}
However in the above summary you can find that 2020-12-15 has 20 documents indexed.
I am running SOLR 8.7.

Copy-transform a numeric field in Solr?

I have a dynamic numeric multivalued field in my solr schema -
<dynamicField name="*_nm" type="float" indexed="true" stored="true" multiValued="true" omitNorms="false"/>
I'd like to run a function score on said field -
_val_:"if(exists(features.width_nm),mul(exp(div(pow(max(0,sub(abs(sub(features.width_nm,12.00000)),0.00000)),2),-51.93702)),10.00000),0.000000)"
but function queries on multivalued fields aren't properly supported in my version of Solr (5.2.1). Trying the above gives the error -
"can not use FieldCache on multivalued field"
My current work-around for this is during indexing to create another field, numeric single-valued, which contains a "reduced" form of the multivalues.
Currently I do this in Java code.
Is there any way for me to do this directly in Solr? for example using a "copy-field"?
Just for completeness - In solr 6.3 I am able to calculate a function-score on a multivalued field by using the field function with a min/max parameter described here.
Thank you very much!

Highlighting Mutivalue field returns String, not List

In Solr, I have several multivalue fields configured, but whenever I query them using highlighting, I get back a single result, instead of a list.
For example, here's my query:
hl=true&
hl.preserveMulti=true&
f.school.hl.alternateField=school&
f.school.hl.fragListBuilder=single&
fl=id,absolute_urlg&
hl.fl=school&
q=university&
start=0&
rows=20&
sort=score+desc&
School is a multiValue field configured like so:
<field name="school"
type="text_en_splitting"
indexed="true"
stored="true"
multiValued="true"
termVectors="true"
termPositions="true"
termOffsets="true"/>
For one document in my collection, school has the value:
[University of California,
Villanova University,
Pitzer College]
The result I want when somebody searches for "University" as they did above is:
["<mark>University</mark> of California",
"Villanova <mark>University</mark>",
"Pitzer College"]
But instead I get:
<mark>University</mark> of California Villanova <mark>University</mark>
Is there something I'm missing? Somehow I'm not getting back a list of results, and values in the multiValue field that don't match aren't being returned.

Sort on field completeness of Solr Documents

I have this Solr field
<field name="listing_thumbnail" type="string" indexed="false" stored="true"/>
Now when the results are shown the fields without the field value should be shown at the last. Is this possible in SOLR? To generalise is it possible to sort documents on field completeness?
You can make use of bq (Boost Query) Parameter of the dismax/edismax query handler. This allows to query if a field is empty or not and then affect the score, but to do so the field needs to be indexed=true.
If you had your field indexed you could add bq=(listing_thumbnail:*) - this would give a push to all documents with a value in that field.

Resources