原生弹性搜索方面的脚本

时间:2013-07-05 09:53:17

标签: elasticsearch facet

是否可以在facet中使用本机脚本?

例如,当我跑:

{
  "facets": {
    "judges": {
      "terms": {
        "field": "judges.untouched",
        "size": 10,
        "all_terms": false,
        "global_facets": true,
        "_script": {
          "script": "facet_matcher",
          "params": {
            "a": "b"
          },
          "lang": "native"
        }
      }
    }
}

它正确使用elasticsearch.yml

中提供的原生方面

但是当我获取更多方面时,elasticsearch无法解析查询:

{
  "facets": {
    "judges": {
      "terms": {
        "field": "judges.untouched",
        "size": 10,
        "all_terms": false,
        "global_facets": true,
        "_script": {
          "script": "facet_matcher",
          "params": {
            "a": "b"
          },
          "lang": "native"
        }
      }
    },
    "judges_selected": {
      "terms": {
        "field": "judges.untouched",
        "size": 10,
        "all_terms": false
      },
      "global_facets": false
    }
  }
}

有错误:

... Parse Failure [No parser for element [judges_selected]]]; }]

我做错了什么?有可能像这样使用facet脚本吗?

由于

1 个答案:

答案 0 :(得分:1)

看起来Elasticsearch只是被_script元素搞糊涂了。试试这个:

{
  "facets": {
    "judges": {
      "terms": {
        "field": "judges.untouched",
        "size": 10,
        "all_terms": false,
        "global_facets": true,
        "script": "facet_matcher",
        "params": {
          "a": "b"
        },
        "lang": "native"
    }
  }
}