我正在尝试运行ElasticSearch查询来计算距离。
说明
我有ElasticSearch检索的公司列表。用户可以按名称和位置搜索公司。这里的位置是问题所在。当我按位置搜索时,我正在失去我的分页。
示例情况:
分页模板:
{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)"
}
}
}