ElasticSearch:请求不支持[script_fields]

时间:2015-10-12 09:05:17

标签: elasticsearch flow-framework

我正在尝试运行ElasticSearch查询来计算距离。

说明

我有ElasticSearch检索的公司列表。用户可以按名称和位置搜索公司。这里的位置是问题所在。当我按位置搜索时,我正在失去我的分页。

示例情况:

  1. 将分页的itemsPerPage设置为10
  2. 运行搜索 - >我可以看到10件物品而且没有分页
  3. 将分页的itemsPerPage设置为2 - >预期结果为5页
  4. 列出了2个项目且没有分页
  5. 分页模板:

    {namespace search=TYPO3\TYPO3CR\Search\ViewHelpers}
    <search:widget.paginate query="{searchQuery}" as="results" configuration="{'itemsPerPage': 2}">
        <ts:render path="searchResultRenderer" context="{searchResults: results}"/>
    </search:widget.paginate>
    

    Java错误:

     org.elasticsearch.index.query.QueryParsingException: [typo3cr-1444378386] request does not support [script_fields]
        at org.elasticsearch.index.query.IndexQueryParserService.parseQuery(IndexQueryParserService.java:360)
        at org.elasticsearch.action.count.TransportCountAction.shardOperation(TransportCountAction.java:187)
        at org.elasticsearch.action.count.TransportCountAction.shardOperation(TransportCountAction.java:66)
        at org.elasticsearch.action.support.broadcast.TransportBroadcastOperationAction$AsyncBroadcastAction$1.run(TransportBroadcastOperationAction.java:170)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
    

    ElasticSearch configuration.yml:

    # The following settings are absolutely required for the CR adaptor to work
    
    script.file: on
    script.inline: sandbox
    script.indexed: sandbox
    
    script.engine.groovy.inline: sandbox
    script.engine.groovy.indexed: sandbox
    
    script.groovy.sandbox.class_whitelist: java.util.LinkedHashMap
    script.groovy.sandbox.receiver_whitelist:  java.util.Iterator, java.lang.Object, java.util.Map, java.util.Map$Entry
    script.groovy.sandbox.enabled: true
    
    # the following settings are well-suited for smaller ElasticSearch instances (e.g. as long as you can stay on one host)
    index.number_of_shards: 1
    index.number_of_replicas: 0
    

    我运行的查询是:

    {
      "query": {
        "filtered": {
          "query": {
            "bool": {
              "must": [
                {
                  "match_all": []
                },
                {
                  "query_string": {
                    "query": "*"
                  }
                }
              ]
            }
          },
          "filter": {
            "bool": {
              "must": [
                {
                  "term": {
                    "__parentPath": "/sites/project"
                  }
                },
                {
                  "terms": {
                    "__workspace": [
                      "live"
                    ]
                  }
                },
                {
                  "term": {
                    "__typeAndSupertypes": "Project:Entry"
                  }
                }
              ],
              "should": [],
              "must_not": [
                {
                  "term": {
                    "_hidden": true
                  }
                },
                {
                  "range": {
                    "_hiddenBeforeDateTime": {
                      "gt": "now"
                    }
                  }
                },
                {
                  "range": {
                    "_hiddenAfterDateTime": {
                      "lt": "now"
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "script_fields": {
        "distance": {
          "script": "doc['coordinates'].distanceInKm(52.39266079999999,9.768640199999936)"
        }
      }
    }
    

0 个答案:

没有答案