Question about Java api vs curl search

Hi

Currently I'm using Elasticsearch 5.5.3 in a project and I have the following query using the Java api ( searchRequestBuilder.toString() )

{
  "from" : 0,
  "size" : 20,
  "query" : {
    "function_score" : {
      "query" : {
        "bool" : {
          "must" : [
            {
              "multi_match" : {
                "query" : "council",
                "fields" : [
                  "description^1.0",
                  "headers.h1^1.7",
                  "headers.h2^1.6",
                  "headers.h3^1.5",
                  "resourceContent.content^1.0",
                  "suggestedDescription^10.0",
                  "title^1.9"
                ],
                "type" : "cross_fields",
                "operator" : "OR",
                "slop" : 0,
                "prefix_length" : 3,
                "max_expansions" : 50,
                "lenient" : false,
                "zero_terms_query" : "NONE",
                "boost" : 1.0
              }
            }
          ],
          "disable_coord" : false,
          "adjust_pure_negative" : true,
          "boost" : 1.0
        }
      },
      "functions" : [
        {
          "filter" : {
            "match_all" : {
              "boost" : 1.0
            }
          },
          "script_score" : {
            "script" : {
              "source" : "fileType=doc['fileType'].value;switch(fileType){case'PAGE':desc=doc['suggestedDescription.keyword'].value;if(!desc?.isEmpty())return _score*20.0f;return _score*16.0f;case'PDF':case'WORD':return _score*10.0f;case'IMAGE':case'VIDEO':return _score*0.9f;default:return _score;}",
              "lang" : "groovy"
            }
          }
        }
      ],
      "score_mode" : "multiply",
      "boost_mode" : "replace",
      "max_boost" : 3.4028235E38,
      "boost" : 1.0
    }
  },
  "_source" : {
    "includes" : [ ],
    "excludes" : [
      "resourceContent",
      "autocomplete",
      "didYouMean"
    ]
  },
  "aggregations" : {
    "fileTypes" : {
      "terms" : {
        "field" : "fileType",
        "size" : 10,
        "min_doc_count" : 1,
        "shard_min_doc_count" : 0,
        "show_term_doc_count_error" : false,
        "order" : [
          {
            "_count" : "desc"
          },
          {
            "_term" : "asc"
          }
        ]
      }
    },
    "entities" : {
      "terms" : {
        "field" : "entity",
        "size" : 10,
        "min_doc_count" : 1,
        "shard_min_doc_count" : 0,
        "show_term_doc_count_error" : false,
        "order" : [
          {
            "_count" : "desc"
          },
          {
            "_term" : "asc"
          }
        ]
      }
    },
    "topics" : {
      "terms" : {
        "field" : "topics",
        "size" : 10,
        "min_doc_count" : 1,
        "shard_min_doc_count" : 0,
        "show_term_doc_count_error" : false,
        "order" : [
          {
            "_count" : "desc"
          },
          {
            "_term" : "asc"
          }
        ]
      }
    },
    "publicationTypes" : {
      "terms" : {
        "field" : "publicationType",
        "size" : 10,
        "min_doc_count" : 1,
        "shard_min_doc_count" : 0,
        "show_term_doc_count_error" : false,
        "order" : [
          {
            "_count" : "desc"
          },
          {
            "_term" : "asc"
          }
        ]
      }
    }
  }
}

This query returns no errors, whereas the same query used with curl (curl -XGET "http://localhost:9200/index/_search" -d"@query.json" produces the folowing errors:

{
	"error": {
		"root_cause": [{
			"type": "parsing_exception",
			"reason": "Fuziness not allowed for type [cross_fields]",
			"line": 1,
			"col": 841
		}],
		"type": "parsing_exception",
		"reason": "Fuziness not allowed for type [cross_fields]",
		"line": 1,
		"col": 841
	},
	"status": 400
}

and

{
	"error": {
		"root_cause": [{
			"type": "illegal_argument_exception",
			"reason": "[script] unknown field [source], parser not found"
		}],
		"type": "illegal_argument_exception",
		"reason": "[script] unknown field [source], parser not found"
	},
	"status": 400
}

The errors are pretty straightforward and easy to fix, but why don't I get these when using the Java api?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.