<p dir="auto">When querying with "preference": "_local" a different JSON parser is used.</p>
<p dir="auto"><code class="notranslate">$ curl -XPUT 'http://ks398280.kimsufi.com:9200/test/test/1' -d '{"user": "foo", "amount": 35, "data": "some more data"}'</code></p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ curl -XPOST 'http://ks398280.kimsufi.com:9200/test/test/_search?pretty' -d  '{
    &quot;query&quot;: {
        &quot;match&quot;: {
            &quot;data&quot;: {
                &quot;query&quot;: &quot;some&quot;
             }
        }
    },
    &quot;fields&quot;: [&quot;user&quot;, &quot;amount&quot;],
}'

{
  &quot;error&quot; : &quot;SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[p5CLZtRvSC-3spyvNBNVng][test][4]: SearchParseException[[test][4]: query[data:some],from[-1],size[-1]: Parse Failure [Failed to parse source [{\n    \&quot;query\&quot;: {\n        \&quot;match\&quot;: {\n            \&quot;data\&quot;: {\n                \&quot;query\&quot;: \&quot;some\&quot;\n             }\n        }\n    },\n    \&quot;fields\&quot;: [\&quot;user\&quot;, \&quot;amount\&quot;],\n}]]]; nested: JsonParseException[Unexpected character ('}' (code 125)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [B@7a04355; line: 10, column: 2]]; }{[p5CLZtRvSC-3spyvNBNVng][test][3]: SearchParseException[[test][3]: query[data:some],from[-1],size[-1]: Parse Failure [Failed to parse source [{\n    \&quot;query\&quot;: {\n        \&quot;match\&quot;: {\n            \&quot;data\&quot;: {\n                \&quot;query\&quot;: \&quot;some\&quot;\n             }\n        }\n    },\n    \&quot;fields\&quot;: [\&quot;user\&quot;, \&quot;amount\&quot;],\n}]]]; nested: JsonParseException[Unexpected character ('}' (code 125)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [B@7a04355; line: 10, column: 2]]; }{[p5CLZtRvSC-3spyvNBNVng][test][2]: SearchParseException[[test][2]: query[data:some],from[-1],size[-1]: Parse Failure [Failed to parse source [{\n    \&quot;query\&quot;: {\n        \&quot;match\&quot;: {\n            \&quot;data\&quot;: {\n                \&quot;query\&quot;: \&quot;some\&quot;\n             }\n        }\n    },\n    \&quot;fields\&quot;: [\&quot;user\&quot;, \&quot;amount\&quot;],\n}]]]; nested: JsonParseException[Unexpected character ('}' (code 125)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [B@7a04355; line: 10, column: 2]]; }{[p5CLZtRvSC-3spyvNBNVng][test][0]: SearchParseException[[test][0]: query[data:some],from[-1],size[-1]: Parse Failure [Failed to parse source [{\n    \&quot;query\&quot;: {\n        \&quot;match\&quot;: {\n            \&quot;data\&quot;: {\n                \&quot;query\&quot;: \&quot;some\&quot;\n             }\n        }\n    },\n    \&quot;fields\&quot;: [\&quot;user\&quot;, \&quot;amount\&quot;],\n}]]]; nested: JsonParseException[Unexpected character ('}' (code 125)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [B@7a04355; line: 10, column: 2]]; }{[p5CLZtRvSC-3spyvNBNVng][test][1]: SearchParseException[[test][1]: query[data:some],from[-1],size[-1]: Parse Failure [Failed to parse source [{\n    \&quot;query\&quot;: {\n        \&quot;match\&quot;: {\n            \&quot;data\&quot;: {\n                \&quot;query\&quot;: \&quot;some\&quot;\n             }\n        }\n    },\n    \&quot;fields\&quot;: [\&quot;user\&quot;, \&quot;amount\&quot;],\n}]]]; nested: JsonParseException[Unexpected character ('}' (code 125)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [B@7a04355; line: 10, column: 2]]; }]&quot;,
  &quot;status&quot; : 400
}"><pre class="notranslate"><span class="pl-ii">$ curl -XPOST 'http://ks398280.kimsufi.com:9200/test/test/_search?pretty' -d  '{</span>
    <span class="pl-ent">"query"</span>: {
        <span class="pl-ent">"match"</span>: {
            <span class="pl-ent">"data"</span>: {
                <span class="pl-ent">"query"</span>: <span class="pl-s"><span class="pl-pds">"</span>some<span class="pl-pds">"</span></span>
             }
        }
    },
    <span class="pl-ent">"fields"</span>: [<span class="pl-s"><span class="pl-pds">"</span>user<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>amount<span class="pl-pds">"</span></span>],
<span class="pl-ii">}'</span>

{
  "error" : "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[p5CLZtRvSC-3spyvNBNVng][test][4]: SearchParseException[[test][4]: query[data:some],from[-1],size[-1]: Parse Failure [Failed to parse source [{\n    \"query\": {\n        \"match\": {\n            \"data\": {\n                \"query\": \"some\"\n             }\n        }\n    },\n    \"fields\": [\"user\", \"amount\"],\n}]]]; nested: JsonParseException[Unexpected character ('}' (code 125)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [B@7a04355; line: 10, column: 2]]; }{[p5CLZtRvSC-3spyvNBNVng][test][3]: SearchParseException[[test][3]: query[data:some],from[-1],size[-1]: Parse Failure [Failed to parse source [{\n    \"query\": {\n        \"match\": {\n            \"data\": {\n                \"query\": \"some\"\n             }\n        }\n    },\n    \"fields\": [\"user\", \"amount\"],\n}]]]; nested: JsonParseException[Unexpected character ('}' (code 125)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [B@7a04355; line: 10, column: 2]]; }{[p5CLZtRvSC-3spyvNBNVng][test][2]: SearchParseException[[test][2]: query[data:some],from[-1],size[-1]: Parse Failure [Failed to parse source [{\n    \"query\": {\n        \"match\": {\n            \"data\": {\n                \"query\": \"some\"\n             }\n        }\n    },\n    \"fields\": [\"user\", \"amount\"],\n}]]]; nested: JsonParseException[Unexpected character ('}' (code 125)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [B@7a04355; line: 10, column: 2]]; }{[p5CLZtRvSC-3spyvNBNVng][test][0]: SearchParseException[[test][0]: query[data:some],from[-1],size[-1]: Parse Failure [Failed to parse source [{\n    \"query\": {\n        \"match\": {\n            \"data\": {\n                \"query\": \"some\"\n             }\n        }\n    },\n    \"fields\": [\"user\", \"amount\"],\n}]]]; nested: JsonParseException[Unexpected character ('}' (code 125)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [B@7a04355; line: 10, column: 2]]; }{[p5CLZtRvSC-3spyvNBNVng][test][1]: SearchParseException[[test][1]: query[data:some],from[-1],size[-1]: Parse Failure [Failed to parse source [{\n    \"query\": {\n        \"match\": {\n            \"data\": {\n                \"query\": \"some\"\n             }\n        }\n    },\n    \"fields\": [\"user\", \"amount\"],\n}]]]; nested: JsonParseException[Unexpected character ('}' (code 125)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [B@7a04355; line: 10, column: 2]]; }]",
  <span class="pl-ent">"status"</span> : <span class="pl-c1">400</span>
}</pre></div>
<p dir="auto">But when using preference _local, the error disappears. Note that the error is the extra comma after the fields.</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ curl -XPOST 'http://ks398280.kimsufi.com:9200/test/test/_search?pretty' -d  '{
    &quot;query&quot;: {
        &quot;match&quot;: {
            &quot;data&quot;: {
                &quot;query&quot;: &quot;some&quot;
             }
        },
        &quot;preference&quot;: &quot;_local&quot;
    },
    &quot;fields&quot;: [&quot;user&quot;, &quot;amount&quot;],
}'

{
  &quot;took&quot; : 1,
  &quot;timed_out&quot; : false,
  &quot;_shards&quot; : {
    &quot;total&quot; : 5,
    &quot;successful&quot; : 5,
    &quot;failed&quot; : 0
  },
  &quot;hits&quot; : {
    &quot;total&quot; : 1,
    &quot;max_score&quot; : 0.15342641,
    &quot;hits&quot; : [ {
      &quot;_index&quot; : &quot;test&quot;,
      &quot;_type&quot; : &quot;test&quot;,
      &quot;_id&quot; : &quot;1&quot;,
      &quot;_score&quot; : 0.15342641, &quot;_source&quot; : {&quot;user&quot;: &quot;foo&quot;, &quot;amount&quot;: 35, &quot;data&quot;: &quot;some more data&quot;}
    } ]
  }
}"><pre class="notranslate"><span class="pl-ii">$ curl -XPOST 'http://ks398280.kimsufi.com:9200/test/test/_search?pretty' -d  '{</span>
    <span class="pl-ent">"query"</span>: {
        <span class="pl-ent">"match"</span>: {
            <span class="pl-ent">"data"</span>: {
                <span class="pl-ent">"query"</span>: <span class="pl-s"><span class="pl-pds">"</span>some<span class="pl-pds">"</span></span>
             }
        },
        <span class="pl-ent">"preference"</span>: <span class="pl-s"><span class="pl-pds">"</span>_local<span class="pl-pds">"</span></span>
    },
    <span class="pl-ent">"fields"</span>: [<span class="pl-s"><span class="pl-pds">"</span>user<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>amount<span class="pl-pds">"</span></span>],
<span class="pl-ii">}'</span>

{
  <span class="pl-ent">"took"</span> : <span class="pl-c1">1</span>,
  <span class="pl-ent">"timed_out"</span> : <span class="pl-c1">false</span>,
  <span class="pl-ent">"_shards"</span> : {
    <span class="pl-ent">"total"</span> : <span class="pl-c1">5</span>,
    <span class="pl-ent">"successful"</span> : <span class="pl-c1">5</span>,
    <span class="pl-ent">"failed"</span> : <span class="pl-c1">0</span>
  },
  <span class="pl-ent">"hits"</span> : {
    <span class="pl-ent">"total"</span> : <span class="pl-c1">1</span>,
    <span class="pl-ent">"max_score"</span> : <span class="pl-c1">0.15342641</span>,
    <span class="pl-ent">"hits"</span> : [ {
      <span class="pl-ent">"_index"</span> : <span class="pl-s"><span class="pl-pds">"</span>test<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"_type"</span> : <span class="pl-s"><span class="pl-pds">"</span>test<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"_id"</span> : <span class="pl-s"><span class="pl-pds">"</span>1<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"_score"</span> : <span class="pl-c1">0.15342641</span>, <span class="pl-ent">"_source"</span> : {<span class="pl-ent">"user"</span>: <span class="pl-s"><span class="pl-pds">"</span>foo<span class="pl-pds">"</span></span>, <span class="pl-ent">"amount"</span>: <span class="pl-c1">35</span>, <span class="pl-ent">"data"</span>: <span class="pl-s"><span class="pl-pds">"</span>some more data<span class="pl-pds">"</span></span>}
    } ]
  }
}</pre></div>
<p dir="auto">When querying with "preference": "_local", the _source is returned instead of the requested fields.</p>
<p dir="auto"><code class="notranslate">$ curl -XPUT 'http://ks398280.kimsufi.com:9200/test/test/1' -d '{"user": "foo", "amount": 35, "data": "some more data"}'</code></p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ curl -XPOST 'http://ks398280.kimsufi.com:9200/test/test/_search?pretty' -d  '{
    &quot;query&quot;: {
        &quot;match&quot;: {
            &quot;data&quot;: {
                &quot;query&quot;: &quot;some&quot;
             }
        }
    },
    &quot;fields&quot;: [&quot;user&quot;, &quot;amount&quot;]
}'

{
  &quot;took&quot; : 1,
  &quot;timed_out&quot; : false,
  &quot;_shards&quot; : {
    &quot;total&quot; : 5,
    &quot;successful&quot; : 5,
    &quot;failed&quot; : 0
  },
  &quot;hits&quot; : {
    &quot;total&quot; : 1,
    &quot;max_score&quot; : 0.15342641,
    &quot;hits&quot; : [ {
      &quot;_index&quot; : &quot;test&quot;,
      &quot;_type&quot; : &quot;test&quot;,
      &quot;_id&quot; : &quot;1&quot;,
      &quot;_score&quot; : 0.15342641,
      &quot;fields&quot; : {
        &quot;amount&quot; : 35,
        &quot;user&quot; : &quot;foo&quot;
      }
    } ]
  }
}"><pre class="notranslate"><span class="pl-ii">$ curl -XPOST 'http://ks398280.kimsufi.com:9200/test/test/_search?pretty' -d  '{</span>
    <span class="pl-ent">"query"</span>: {
        <span class="pl-ent">"match"</span>: {
            <span class="pl-ent">"data"</span>: {
                <span class="pl-ent">"query"</span>: <span class="pl-s"><span class="pl-pds">"</span>some<span class="pl-pds">"</span></span>
             }
        }
    },
    <span class="pl-ent">"fields"</span>: [<span class="pl-s"><span class="pl-pds">"</span>user<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>amount<span class="pl-pds">"</span></span>]
<span class="pl-ii">}'</span>

{
  <span class="pl-ent">"took"</span> : <span class="pl-c1">1</span>,
  <span class="pl-ent">"timed_out"</span> : <span class="pl-c1">false</span>,
  <span class="pl-ent">"_shards"</span> : {
    <span class="pl-ent">"total"</span> : <span class="pl-c1">5</span>,
    <span class="pl-ent">"successful"</span> : <span class="pl-c1">5</span>,
    <span class="pl-ent">"failed"</span> : <span class="pl-c1">0</span>
  },
  <span class="pl-ent">"hits"</span> : {
    <span class="pl-ent">"total"</span> : <span class="pl-c1">1</span>,
    <span class="pl-ent">"max_score"</span> : <span class="pl-c1">0.15342641</span>,
    <span class="pl-ent">"hits"</span> : [ {
      <span class="pl-ent">"_index"</span> : <span class="pl-s"><span class="pl-pds">"</span>test<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"_type"</span> : <span class="pl-s"><span class="pl-pds">"</span>test<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"_id"</span> : <span class="pl-s"><span class="pl-pds">"</span>1<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"_score"</span> : <span class="pl-c1">0.15342641</span>,
      <span class="pl-ent">"fields"</span> : {
        <span class="pl-ent">"amount"</span> : <span class="pl-c1">35</span>,
        <span class="pl-ent">"user"</span> : <span class="pl-s"><span class="pl-pds">"</span>foo<span class="pl-pds">"</span></span>
      }
    } ]
  }
}</pre></div>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ curl -XPOST 'http://ks398280.kimsufi.com:9200/test/test/_search?pretty' -d  '{
    &quot;query&quot;: {
        &quot;match&quot;: {
            &quot;data&quot;: {
                &quot;query&quot;: &quot;some&quot;
             }
        },
        &quot;preference&quot;: &quot;_local&quot;
    },
    &quot;fields&quot;: [&quot;user&quot;, &quot;amount&quot;],
}'

{
  &quot;took&quot; : 1,
  &quot;timed_out&quot; : false,
  &quot;_shards&quot; : {
    &quot;total&quot; : 5,
    &quot;successful&quot; : 5,
    &quot;failed&quot; : 0
  },
  &quot;hits&quot; : {
    &quot;total&quot; : 1,
    &quot;max_score&quot; : 0.15342641,
    &quot;hits&quot; : [ {
      &quot;_index&quot; : &quot;test&quot;,
      &quot;_type&quot; : &quot;test&quot;,
      &quot;_id&quot; : &quot;1&quot;,
      &quot;_score&quot; : 0.15342641, &quot;_source&quot; : {&quot;user&quot;: &quot;foo&quot;, &quot;amount&quot;: 35, &quot;data&quot;: &quot;some more data&quot;}
    } ]
  }
}"><pre class="notranslate"><span class="pl-ii">$ curl -XPOST 'http://ks398280.kimsufi.com:9200/test/test/_search?pretty' -d  '{</span>
    <span class="pl-ent">"query"</span>: {
        <span class="pl-ent">"match"</span>: {
            <span class="pl-ent">"data"</span>: {
                <span class="pl-ent">"query"</span>: <span class="pl-s"><span class="pl-pds">"</span>some<span class="pl-pds">"</span></span>
             }
        },
        <span class="pl-ent">"preference"</span>: <span class="pl-s"><span class="pl-pds">"</span>_local<span class="pl-pds">"</span></span>
    },
    <span class="pl-ent">"fields"</span>: [<span class="pl-s"><span class="pl-pds">"</span>user<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>amount<span class="pl-pds">"</span></span>],
<span class="pl-ii">}'</span>

{
  <span class="pl-ent">"took"</span> : <span class="pl-c1">1</span>,
  <span class="pl-ent">"timed_out"</span> : <span class="pl-c1">false</span>,
  <span class="pl-ent">"_shards"</span> : {
    <span class="pl-ent">"total"</span> : <span class="pl-c1">5</span>,
    <span class="pl-ent">"successful"</span> : <span class="pl-c1">5</span>,
    <span class="pl-ent">"failed"</span> : <span class="pl-c1">0</span>
  },
  <span class="pl-ent">"hits"</span> : {
    <span class="pl-ent">"total"</span> : <span class="pl-c1">1</span>,
    <span class="pl-ent">"max_score"</span> : <span class="pl-c1">0.15342641</span>,
    <span class="pl-ent">"hits"</span> : [ {
      <span class="pl-ent">"_index"</span> : <span class="pl-s"><span class="pl-pds">"</span>test<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"_type"</span> : <span class="pl-s"><span class="pl-pds">"</span>test<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"_id"</span> : <span class="pl-s"><span class="pl-pds">"</span>1<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"_score"</span> : <span class="pl-c1">0.15342641</span>, <span class="pl-ent">"_source"</span> : {<span class="pl-ent">"user"</span>: <span class="pl-s"><span class="pl-pds">"</span>foo<span class="pl-pds">"</span></span>, <span class="pl-ent">"amount"</span>: <span class="pl-c1">35</span>, <span class="pl-ent">"data"</span>: <span class="pl-s"><span class="pl-pds">"</span>some more data<span class="pl-pds">"</span></span>}
    } ]
  }
}</pre></div>