Hello, I am trying to follow the *field collapse example* on this page 
<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html#_field_collapse_example>,
 
which uses the new 1.3.0 *top_hits* aggregator to return the top scoring 
document for a given criteria. To my knowledge, I set up the settings and 
mappings correctly, but I am getting a strange error when I try to run the 
query that the example provided.

curl -XDELETE "http://localhost:9200/personsearch";
curl -XPUT "http://localhost:9200/personsearch"; -d'
{
  "settings": {
    "index": {
      "analysis": {
        "analyzer": {
          "idx_analyzer": {
            "tokenizer": "whitespace",
            "filter": [
              "lowercase",
              "snowball",
              "XYZSynFilter"
            ]
          },
          "sch_analyzer": {
            "tokenizer": "standard",
            "filter": [
              "standard",
              "lowercase",
              "stop"
            ]
          },
          "sch_comma_analyzer": {
            "tokenizer": "CommaTokenizer",
            "filter": [
              "standard",
              "lowercase",
              "stop"
            ]
          }
        },
        "filter": {
          "XYZSynFilter": {
            "type": "synonym",
            "synonyms": [
              "aids virus, aids, retrovirology, hiv"
            ],
            "expand": true,
            "ignore_case": true
          }
        },
        "tokenizer": {
          "CommaTokenizer": {
            "type": "pattern",
            "pattern": ","
          }
        }
      }
    }
  },
  "mappings": {
    "employees": {
      "properties": {
        "fullName": {
          "type": "string",
          "search_analyzer": "sch_analyzer"
        },
        "specialty": {
          "type": "string",
          "search_analyzer": "sch_comma_analyzer"
        }
      }
    }
  }
}'
curl -XPUT "http://localhost:9200/personsearch/employees/1"; -d'
{
  "fullName": "Don White",
  "specialty": "Adult Retrovirology, aids, hiv"
}'
curl -XPUT "http://localhost:9200/personsearch/employees/2"; -d'
{
  "fullName": "Don White",
  "specialty": "general practitioner, physician, general, primary care"
}'
curl -XPUT "http://localhost:9200/personsearch/employees/3"; -d'
{
  "fullName": "Don White",
  "specialty": "icu, er"
}'
curl -XPUT "http://localhost:9200/personsearch/employees/4"; -d'
{
  "fullName": "Terrance Gartner",
  "specialty": "oncology, cancer, research, tumor, polyp"
}'
curl -XPUT "http://localhost:9200/personsearch/employees/5"; -d'
{
  "fullName": "Terrance Gartner",
  "specialty": "physician, general, GP, primary care, aids"
}'
curl -XPUT "http://localhost:9200/personsearch/employees/6"; -d'
{
  "fullName": "Terrance Gartner",
  "specialty": "emergency care, icu, ambulance, er, urgent"
}'
curl -XPUT "http://localhost:9200/personsearch/employees/7"; -d'
{
  "fullName": "Carter Taylor",
  "specialty": "neurosurgery, brain surgery, brain tumor"
}'
curl -XPUT "http://localhost:9200/personsearch/employees/8"; -d'
{
  "fullName": "Carter Taylor",
  "specialty": "trauma, icu, emergency care, ER, urgent care"
}'


Executing this search (per the example) gives me an error
curl -XGET 
"http://localhost:9200/personsearch/employees/_search?pretty=true"; -d'
{
  "query": {
    "query_string": {
      "query": "icu"
    }
  },
  "aggs": {
    "most-rel-profile": {
      "terms": {
        "field": "profileName",
        "order": {
          "top_hit": "desc"
        }
      },
      "aggs": {
        "top_tags_hits": {
          "top_hits": {}
        },
        "top_hit": {
          "max": {
            "script": "_doc.score"
          }
        }
      }
    }
  }
}'



{
   "error": "SearchPhaseExecutionException[Failed to execute phase [query], 
all shards failed; shardFailures 
{[4gtV_OJESWWSgMnbTruKyA][personsearch][0]: 
SearchParseException[[personsearch][0]: query[_all:icu],from[-1],size[-1]: 
Parse Failure [Failed to parse source [{\n  \"query\": {\n   
 \"query_string\": {\n      \"query\": \"icu\"\n    }\n  },\n  \"aggs\": 
{\n    \"most-rel-profile\": {\n      \"terms\": {\n        \"field\": 
\"profileName\",\n        \"order\": {\n          \"top_hit\": \"desc\"\n   
     }\n      },\n      \"aggs\": {\n        \"top_tags_hits\": {\n         
 \"top_hits\": {}\n        },\n        \"top_hit\": {\n          \"max\": 
{\n            \"script\": \"_doc.score\"\n          }\n        }\n     
 }\n    }\n  }\n}\n]]]; nested: ScriptException[dynamic scripting for 
[mvel] disabled]; }{[4gtV_OJESWWSgMnbTruKyA][personsearch][1]: 
SearchParseException[[personsearch][1]: query[_all:icu],from[-1],size[-1]: 
Parse Failure [Failed to parse source [{\n  \"query\": {\n   
 \"query_string\": {\n      \"query\": \"icu\"\n    }\n  },\n  \"aggs\": 
{\n    \"most-rel-profile\": {\n      \"terms\": {\n        \"field\": 
\"profileName\",\n        \"order\": {\n          \"top_hit\": \"desc\"\n   
     }\n      },\n      \"aggs\": {\n        \"top_tags_hits\": {\n         
 \"top_hits\": {}\n        },\n        \"top_hit\": {\n          \"max\": 
{\n            \"script\": \"_doc.score\"\n          }\n        }\n     
 }\n    }\n  }\n}\n]]]; nested: ScriptException[dynamic scripting for 
[mvel] disabled]; }{[4gtV_OJESWWSgMnbTruKyA][personsearch][2]: 
SearchParseException[[personsearch][2]: query[_all:icu],from[-1],size[-1]: 
Parse Failure [Failed to parse source [{\n  \"query\": {\n   
 \"query_string\": {\n      \"query\": \"icu\"\n    }\n  },\n  \"aggs\": 
{\n    \"most-rel-profile\": {\n      \"terms\": {\n        \"field\": 
\"profileName\",\n        \"order\": {\n          \"top_hit\": \"desc\"\n   
     }\n      },\n      \"aggs\": {\n        \"top_tags_hits\": {\n         
 \"top_hits\": {}\n        },\n        \"top_hit\": {\n          \"max\": 
{\n            \"script\": \"_doc.score\"\n          }\n        }\n     
 }\n    }\n  }\n}\n]]]; nested: ScriptException[dynamic scripting for 
[mvel] disabled]; }{[4gtV_OJESWWSgMnbTruKyA][personsearch][3]: 
SearchParseException[[personsearch][3]: query[_all:icu],from[-1],size[-1]: 
Parse Failure [Failed to parse source [{\n  \"query\": {\n   
 \"query_string\": {\n      \"query\": \"icu\"\n    }\n  },\n  \"aggs\": 
{\n    \"most-rel-profile\": {\n      \"terms\": {\n        \"field\": 
\"profileName\",\n        \"order\": {\n          \"top_hit\": \"desc\"\n   
     }\n      },\n      \"aggs\": {\n        \"top_tags_hits\": {\n         
 \"top_hits\": {}\n        },\n        \"top_hit\": {\n          \"max\": 
{\n            \"script\": \"_doc.score\"\n          }\n        }\n     
 }\n    }\n  }\n}\n]]]; nested: ScriptException[dynamic scripting for 
[mvel] disabled]; }{[4gtV_OJESWWSgMnbTruKyA][personsearch][4]: 
SearchParseException[[personsearch][4]: query[_all:icu],from[-1],size[-1]: 
Parse Failure [Failed to parse source [{\n  \"query\": {\n   
 \"query_string\": {\n      \"query\": \"icu\"\n    }\n  },\n  \"aggs\": 
{\n    \"most-rel-profile\": {\n      \"terms\": {\n        \"field\": 
\"profileName\",\n        \"order\": {\n          \"top_hit\": \"desc\"\n   
     }\n      },\n      \"aggs\": {\n        \"top_tags_hits\": {\n         
 \"top_hits\": {}\n        },\n        \"top_hit\": {\n          \"max\": 
{\n            \"script\": \"_doc.score\"\n          }\n        }\n     
 }\n    }\n  }\n}\n]]]; nested:* ScriptException[dynamic scripting for 
[mvel] disabled];* }]",
   "status": 400
}


Does the *dynamic scripting for [mvel] disabled* have something to do with 
it?


Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/79c1fff8-78a4-4419-a87d-e39ec3148fcf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to