簡體   English   中英

Apache Solr:如何將所有動態字段添加到 stats.field

[英]Apache Solr: How to add all the dynamic fileds to the stats.field

我是 apache solr 的新手,我需要一些有關查詢的幫助。 我在 solr 模式中創建了一些動態字段,這些字段因文檔而異。 現在我需要運行一個查詢,我可以在其中獲取 stats 部分下的所有動態字段以創建過濾器,以便我可以對搜索結果運行過濾器查詢。

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

在上面的查詢中,很少有帶有后綴 _sm 的動態字段,我希望在 stats 部分下的搜索結果中所有字​​段都具有相同的后綴。

以下是上述查詢的輸出,但 stats_fields 僅列出我在查詢中定義的那些列,還有一些我希望在結果 json 中的動態列,但不應單獨在查詢中定義。

{
  "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
      }
    }
  }
}

我需要一些幫助來解決這個問題,請讓我知道 solr 是否允許這樣做,如果是,那么我該如何實現。

可以將動態字段定義為stats.field

Solr Stats 組件示例中查看他們如何使用stats.field={!func}termfreq('text','memory')

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM