Search in multiple index , 'query_shard_exception' when fields are not present











up vote
0
down vote

favorite












I'm trying to search in multiple indexes, but the fields and mapping for each index are different. Like one index is having nested path.



When I'm trying to query on index's I'm getting error for the index which are not having the nested path.



    {
"query": {
"bool": {
"should": [
{
"term": {
"a": "good"
}
},
{
"term": {
"a.b": "sample"
}
},
{
"nested": {
"path": "x.y.z",
"query": {
"bool": {
"should": [
{
"term": {
"x.y.z.id.keyword": "test@gamil.com"
}
}
]
}
}
}
}
]
}
}
}


in above the nested path x.y.z is only present for one index.



I tried finding a solution, found ignore_unavailable. But it will ignore the index not having nested path, but I need the document's in that index which matches other condition in the query.










share|improve this question


























    up vote
    0
    down vote

    favorite












    I'm trying to search in multiple indexes, but the fields and mapping for each index are different. Like one index is having nested path.



    When I'm trying to query on index's I'm getting error for the index which are not having the nested path.



        {
    "query": {
    "bool": {
    "should": [
    {
    "term": {
    "a": "good"
    }
    },
    {
    "term": {
    "a.b": "sample"
    }
    },
    {
    "nested": {
    "path": "x.y.z",
    "query": {
    "bool": {
    "should": [
    {
    "term": {
    "x.y.z.id.keyword": "test@gamil.com"
    }
    }
    ]
    }
    }
    }
    }
    ]
    }
    }
    }


    in above the nested path x.y.z is only present for one index.



    I tried finding a solution, found ignore_unavailable. But it will ignore the index not having nested path, but I need the document's in that index which matches other condition in the query.










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm trying to search in multiple indexes, but the fields and mapping for each index are different. Like one index is having nested path.



      When I'm trying to query on index's I'm getting error for the index which are not having the nested path.



          {
      "query": {
      "bool": {
      "should": [
      {
      "term": {
      "a": "good"
      }
      },
      {
      "term": {
      "a.b": "sample"
      }
      },
      {
      "nested": {
      "path": "x.y.z",
      "query": {
      "bool": {
      "should": [
      {
      "term": {
      "x.y.z.id.keyword": "test@gamil.com"
      }
      }
      ]
      }
      }
      }
      }
      ]
      }
      }
      }


      in above the nested path x.y.z is only present for one index.



      I tried finding a solution, found ignore_unavailable. But it will ignore the index not having nested path, but I need the document's in that index which matches other condition in the query.










      share|improve this question













      I'm trying to search in multiple indexes, but the fields and mapping for each index are different. Like one index is having nested path.



      When I'm trying to query on index's I'm getting error for the index which are not having the nested path.



          {
      "query": {
      "bool": {
      "should": [
      {
      "term": {
      "a": "good"
      }
      },
      {
      "term": {
      "a.b": "sample"
      }
      },
      {
      "nested": {
      "path": "x.y.z",
      "query": {
      "bool": {
      "should": [
      {
      "term": {
      "x.y.z.id.keyword": "test@gamil.com"
      }
      }
      ]
      }
      }
      }
      }
      ]
      }
      }
      }


      in above the nested path x.y.z is only present for one index.



      I tried finding a solution, found ignore_unavailable. But it will ignore the index not having nested path, but I need the document's in that index which matches other condition in the query.







      elasticsearch elasticsearch-5






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 at 6:53









      yureka

      117




      117
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Try the following query by replacing your-index with the name of the index that contains the nested field.



          {
          "query": {
          "bool": {
          "should": [
          {
          "term": {
          "a": "good"
          }
          },
          {
          "term": {
          "a.b": "sample"
          }
          },
          {
          "bool": {
          "must": [
          {
          "term": {
          "_index": "your-index"
          }
          },
          {
          "nested": {
          "path": "x.y.z",
          "query": {
          "bool": {
          "should": [
          {
          "term": {
          "x.y.z.id.keyword": "test@gamil.com"
          }
          }
          ]
          }
          }
          }
          }
          ]
          }
          }
          ]
          }
          }
          }





          share|improve this answer





















          • still getting [nested] failed to find nested object under path
            – yureka
            Nov 12 at 9:14












          • Can you share your mapping?
            – Val
            Nov 26 at 18:23










          • { nested: { path: "a/b/c", ignore_unmapped: true, query: { bool: { should: } } } Was able to solve issue by adding ignore_unmapped: true
            – yureka
            Nov 27 at 15:51













          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',
          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%2f53257160%2fsearch-in-multiple-index-query-shard-exception-when-fields-are-not-present%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          Try the following query by replacing your-index with the name of the index that contains the nested field.



          {
          "query": {
          "bool": {
          "should": [
          {
          "term": {
          "a": "good"
          }
          },
          {
          "term": {
          "a.b": "sample"
          }
          },
          {
          "bool": {
          "must": [
          {
          "term": {
          "_index": "your-index"
          }
          },
          {
          "nested": {
          "path": "x.y.z",
          "query": {
          "bool": {
          "should": [
          {
          "term": {
          "x.y.z.id.keyword": "test@gamil.com"
          }
          }
          ]
          }
          }
          }
          }
          ]
          }
          }
          ]
          }
          }
          }





          share|improve this answer





















          • still getting [nested] failed to find nested object under path
            – yureka
            Nov 12 at 9:14












          • Can you share your mapping?
            – Val
            Nov 26 at 18:23










          • { nested: { path: "a/b/c", ignore_unmapped: true, query: { bool: { should: } } } Was able to solve issue by adding ignore_unmapped: true
            – yureka
            Nov 27 at 15:51

















          up vote
          0
          down vote













          Try the following query by replacing your-index with the name of the index that contains the nested field.



          {
          "query": {
          "bool": {
          "should": [
          {
          "term": {
          "a": "good"
          }
          },
          {
          "term": {
          "a.b": "sample"
          }
          },
          {
          "bool": {
          "must": [
          {
          "term": {
          "_index": "your-index"
          }
          },
          {
          "nested": {
          "path": "x.y.z",
          "query": {
          "bool": {
          "should": [
          {
          "term": {
          "x.y.z.id.keyword": "test@gamil.com"
          }
          }
          ]
          }
          }
          }
          }
          ]
          }
          }
          ]
          }
          }
          }





          share|improve this answer





















          • still getting [nested] failed to find nested object under path
            – yureka
            Nov 12 at 9:14












          • Can you share your mapping?
            – Val
            Nov 26 at 18:23










          • { nested: { path: "a/b/c", ignore_unmapped: true, query: { bool: { should: } } } Was able to solve issue by adding ignore_unmapped: true
            – yureka
            Nov 27 at 15:51















          up vote
          0
          down vote










          up vote
          0
          down vote









          Try the following query by replacing your-index with the name of the index that contains the nested field.



          {
          "query": {
          "bool": {
          "should": [
          {
          "term": {
          "a": "good"
          }
          },
          {
          "term": {
          "a.b": "sample"
          }
          },
          {
          "bool": {
          "must": [
          {
          "term": {
          "_index": "your-index"
          }
          },
          {
          "nested": {
          "path": "x.y.z",
          "query": {
          "bool": {
          "should": [
          {
          "term": {
          "x.y.z.id.keyword": "test@gamil.com"
          }
          }
          ]
          }
          }
          }
          }
          ]
          }
          }
          ]
          }
          }
          }





          share|improve this answer












          Try the following query by replacing your-index with the name of the index that contains the nested field.



          {
          "query": {
          "bool": {
          "should": [
          {
          "term": {
          "a": "good"
          }
          },
          {
          "term": {
          "a.b": "sample"
          }
          },
          {
          "bool": {
          "must": [
          {
          "term": {
          "_index": "your-index"
          }
          },
          {
          "nested": {
          "path": "x.y.z",
          "query": {
          "bool": {
          "should": [
          {
          "term": {
          "x.y.z.id.keyword": "test@gamil.com"
          }
          }
          ]
          }
          }
          }
          }
          ]
          }
          }
          ]
          }
          }
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 12 at 8:10









          Val

          100k6130167




          100k6130167












          • still getting [nested] failed to find nested object under path
            – yureka
            Nov 12 at 9:14












          • Can you share your mapping?
            – Val
            Nov 26 at 18:23










          • { nested: { path: "a/b/c", ignore_unmapped: true, query: { bool: { should: } } } Was able to solve issue by adding ignore_unmapped: true
            – yureka
            Nov 27 at 15:51




















          • still getting [nested] failed to find nested object under path
            – yureka
            Nov 12 at 9:14












          • Can you share your mapping?
            – Val
            Nov 26 at 18:23










          • { nested: { path: "a/b/c", ignore_unmapped: true, query: { bool: { should: } } } Was able to solve issue by adding ignore_unmapped: true
            – yureka
            Nov 27 at 15:51


















          still getting [nested] failed to find nested object under path
          – yureka
          Nov 12 at 9:14






          still getting [nested] failed to find nested object under path
          – yureka
          Nov 12 at 9:14














          Can you share your mapping?
          – Val
          Nov 26 at 18:23




          Can you share your mapping?
          – Val
          Nov 26 at 18:23












          { nested: { path: "a/b/c", ignore_unmapped: true, query: { bool: { should: } } } Was able to solve issue by adding ignore_unmapped: true
          – yureka
          Nov 27 at 15:51






          { nested: { path: "a/b/c", ignore_unmapped: true, query: { bool: { should: } } } Was able to solve issue by adding ignore_unmapped: true
          – yureka
          Nov 27 at 15:51




















          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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2f53257160%2fsearch-in-multiple-index-query-shard-exception-when-fields-are-not-present%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







          Popular posts from this blog

          Bressuire

          Vorschmack

          Quarantine