I am new to apache solr, I need some help regarding a query. I have created some dynamic fields in solr schema which vary document to document. Now I need to run a query where I can get all the dynamic fields under the stats section to create a filter so that i can run filter queries on the searched result.
http://localhost:8983/solr/catalog/select?fq=color_sm%3A(*%22black%22)&q=product_name%3AMouse&stats=true&stats.calcdistinct=true&stats.field=height_sm&stats.field=color_sm&stats.field=height_i&rows=0
in above query there are few dynamic fields with suffix _sm and i want all the fields having same suffix in the search result under stats section.
Following is the output of above query, but stats_fields is listing only those columns I've defined in query, there are some more dynamic columns which i wants to be in result json but it shouldn't be defined in query separately.
{
"responseHeader": {
"status": 0,
"QTime": 2,
"params": {
"q": "product_name:Mouse",
"stats.calcdistinct": "true",
"stats": "true",
"fq": "color_sm:(*\"black\")",
"rows": "0",
"stats.field": [
"height_sm",
"color_sm"
]
}
},
"response": {
"numFound": 10,
"start": 0,
"docs": [
]
},
"stats": {
"stats_fields": {
"height_sm": {
"min": "30 Centimeters",
"max": "45 Centimeters",
"count": 2,
"missing": 0,
"distinctValues": [
"30 Centimeters",
"45 Centimeters"
],
"countDistinct": 2
},
"color_sm": {
"min": "Black",
"max": "White",
"count": 3,
"missing": 0,
"distinctValues": [
"Black",
"Gray",
"White"
],
"countDistinct": 3
}
}
}
}
I need some help to solve this, kindly let me know if solr allows to do so and if yes then how i can achieve this.
It's possible to define dynamic fields as stats.field
.
See how they use stats.field={!func}termfreq('text','memory')
in the Solr Stats Component example :
http://localhost:8983/solr/techproducts/select?q=*:*&wt=xml&stats=true&stats.field={!func}termfreq('text','memory')&stats.field=price&stats.field=popularity&rows=0&indent=true
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.