Elasticsearch query using more_like_this field renders a failed to parse search source. expected field name but got [START_OBJECT] error










1















We're using Elasticsearch 2.4.5. Have an application that can generate fairly complicated queries. I'm trying to add a more_like_this field to the query like so:




"query":
"more_like_this":
"fields": [
"title"
],
"ids": [
1234
],
"min_term_freq": 1,
"max_query_terms": 25
,
"function_score":
"query":
"bool":
"must": [

"query_string":
"default_operator": "AND",
"fields": [
"title",
"author"
],
"query": "((title:("Tale of Two Cities"^2)))",
"lenient": true


],
"filter":
"bool":
"must": [

"bool":
"should": [

"geo_distance":
"distance": "50mi",
"location":
"lat": 49.32,
"lon": -45.67
,
"distance_type": "plane",
"_cache": true


]

,

"term":
"merged": 0

,

"bool":
"must_not":
"exists":
"field": "title_type"




]



,
"functions": [

"field_value_factor":
"field": "quality_score",
"factor": 1,
"missing": 0


]

,
"filter":
"bool":
"must":

,
"sort": "_score",
"size": 20,
"from": 0



I'm getting a failed to parse search source. expected field name but got [START_OBJECT] error when I try to run the above code. When I remove that piece of code the query executes correctly. I've looked at documentation and other examples of more_like_this usage and I can't determine what's wrong with my query. I'm assuming it has something to do with the way the rest of the query is formed.










share|improve this question
























  • What version of elasticsearch do you use? What happens if you remove "ids":[...] and add "like" : "1234" instead?

    – ttomalak
    Nov 14 '18 at 20:21











  • @ttomalak - We're using 2.4.5 (I updated the question text to reflect this). When I change ids: [...] to like: "1234" I sadly get the same error.

    – TheNovice
    Nov 14 '18 at 20:29















1















We're using Elasticsearch 2.4.5. Have an application that can generate fairly complicated queries. I'm trying to add a more_like_this field to the query like so:




"query":
"more_like_this":
"fields": [
"title"
],
"ids": [
1234
],
"min_term_freq": 1,
"max_query_terms": 25
,
"function_score":
"query":
"bool":
"must": [

"query_string":
"default_operator": "AND",
"fields": [
"title",
"author"
],
"query": "((title:("Tale of Two Cities"^2)))",
"lenient": true


],
"filter":
"bool":
"must": [

"bool":
"should": [

"geo_distance":
"distance": "50mi",
"location":
"lat": 49.32,
"lon": -45.67
,
"distance_type": "plane",
"_cache": true


]

,

"term":
"merged": 0

,

"bool":
"must_not":
"exists":
"field": "title_type"




]



,
"functions": [

"field_value_factor":
"field": "quality_score",
"factor": 1,
"missing": 0


]

,
"filter":
"bool":
"must":

,
"sort": "_score",
"size": 20,
"from": 0



I'm getting a failed to parse search source. expected field name but got [START_OBJECT] error when I try to run the above code. When I remove that piece of code the query executes correctly. I've looked at documentation and other examples of more_like_this usage and I can't determine what's wrong with my query. I'm assuming it has something to do with the way the rest of the query is formed.










share|improve this question
























  • What version of elasticsearch do you use? What happens if you remove "ids":[...] and add "like" : "1234" instead?

    – ttomalak
    Nov 14 '18 at 20:21











  • @ttomalak - We're using 2.4.5 (I updated the question text to reflect this). When I change ids: [...] to like: "1234" I sadly get the same error.

    – TheNovice
    Nov 14 '18 at 20:29













1












1








1








We're using Elasticsearch 2.4.5. Have an application that can generate fairly complicated queries. I'm trying to add a more_like_this field to the query like so:




"query":
"more_like_this":
"fields": [
"title"
],
"ids": [
1234
],
"min_term_freq": 1,
"max_query_terms": 25
,
"function_score":
"query":
"bool":
"must": [

"query_string":
"default_operator": "AND",
"fields": [
"title",
"author"
],
"query": "((title:("Tale of Two Cities"^2)))",
"lenient": true


],
"filter":
"bool":
"must": [

"bool":
"should": [

"geo_distance":
"distance": "50mi",
"location":
"lat": 49.32,
"lon": -45.67
,
"distance_type": "plane",
"_cache": true


]

,

"term":
"merged": 0

,

"bool":
"must_not":
"exists":
"field": "title_type"




]



,
"functions": [

"field_value_factor":
"field": "quality_score",
"factor": 1,
"missing": 0


]

,
"filter":
"bool":
"must":

,
"sort": "_score",
"size": 20,
"from": 0



I'm getting a failed to parse search source. expected field name but got [START_OBJECT] error when I try to run the above code. When I remove that piece of code the query executes correctly. I've looked at documentation and other examples of more_like_this usage and I can't determine what's wrong with my query. I'm assuming it has something to do with the way the rest of the query is formed.










share|improve this question
















We're using Elasticsearch 2.4.5. Have an application that can generate fairly complicated queries. I'm trying to add a more_like_this field to the query like so:




"query":
"more_like_this":
"fields": [
"title"
],
"ids": [
1234
],
"min_term_freq": 1,
"max_query_terms": 25
,
"function_score":
"query":
"bool":
"must": [

"query_string":
"default_operator": "AND",
"fields": [
"title",
"author"
],
"query": "((title:("Tale of Two Cities"^2)))",
"lenient": true


],
"filter":
"bool":
"must": [

"bool":
"should": [

"geo_distance":
"distance": "50mi",
"location":
"lat": 49.32,
"lon": -45.67
,
"distance_type": "plane",
"_cache": true


]

,

"term":
"merged": 0

,

"bool":
"must_not":
"exists":
"field": "title_type"




]



,
"functions": [

"field_value_factor":
"field": "quality_score",
"factor": 1,
"missing": 0


]

,
"filter":
"bool":
"must":

,
"sort": "_score",
"size": 20,
"from": 0



I'm getting a failed to parse search source. expected field name but got [START_OBJECT] error when I try to run the above code. When I remove that piece of code the query executes correctly. I've looked at documentation and other examples of more_like_this usage and I can't determine what's wrong with my query. I'm assuming it has something to do with the way the rest of the query is formed.







elasticsearch search morelikethis






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 20:28







TheNovice

















asked Nov 14 '18 at 19:45









TheNoviceTheNovice

3792417




3792417












  • What version of elasticsearch do you use? What happens if you remove "ids":[...] and add "like" : "1234" instead?

    – ttomalak
    Nov 14 '18 at 20:21











  • @ttomalak - We're using 2.4.5 (I updated the question text to reflect this). When I change ids: [...] to like: "1234" I sadly get the same error.

    – TheNovice
    Nov 14 '18 at 20:29

















  • What version of elasticsearch do you use? What happens if you remove "ids":[...] and add "like" : "1234" instead?

    – ttomalak
    Nov 14 '18 at 20:21











  • @ttomalak - We're using 2.4.5 (I updated the question text to reflect this). When I change ids: [...] to like: "1234" I sadly get the same error.

    – TheNovice
    Nov 14 '18 at 20:29
















What version of elasticsearch do you use? What happens if you remove "ids":[...] and add "like" : "1234" instead?

– ttomalak
Nov 14 '18 at 20:21





What version of elasticsearch do you use? What happens if you remove "ids":[...] and add "like" : "1234" instead?

– ttomalak
Nov 14 '18 at 20:21













@ttomalak - We're using 2.4.5 (I updated the question text to reflect this). When I change ids: [...] to like: "1234" I sadly get the same error.

– TheNovice
Nov 14 '18 at 20:29





@ttomalak - We're using 2.4.5 (I updated the question text to reflect this). When I change ids: [...] to like: "1234" I sadly get the same error.

– TheNovice
Nov 14 '18 at 20:29












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53307716%2felasticsearch-query-using-more-like-this-field-renders-a-failed-to-parse-search%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53307716%2felasticsearch-query-using-more-like-this-field-renders-a-failed-to-parse-search%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3

Museum of Modern and Contemporary Art of Trento and Rovereto