Empty String elastic search












0















I'm using Elastic 6.5 .



I need to include an empty string search with one of the criteria i'm passing.



primaryKey = 1, 2, 3



subKey = "" or subKey = "A" along with a bunch of other criteria.



I've been unable to get the record that has the empty subKey.



i've tried using the MUST_NOT EXISTS but it doesn't fetch the record in question.



So below should return any records that have primarykey of 1, 2, or 3. and subKey of 'A' or Empty String. Filtered by the Date provided. I get all the records Except the record where the subKey is blank.



so i've tried this:



{
"size": 200, "from": 0,
"query": {
"bool": {
"must": [{
"bool": {
"should": [{ "terms": {"primaryKey": [1,2,3] }}]
}
},
{
"bool": {
"should": [
{"match": {"subKey": "A"}},
{
"bool" : {
"must_not": [{ "exists": { "field": "subKey"} }]
}
}
]
}
}],
"filter": [{"range": {"startdate": {"lte": "2018-11-01"}}}]
}
}
}


The subkey field is special.. where it's actually searched by LETTER. But i don't think that effects anything.. but here is the NEST coding i have for that index.



new CreateIndexDescriptor("SpecialIndex").Settings(s => s
.Analysis(a => a
.Analyzers(aa => aa
.Custom("subKey_analyzer", ma => ma
.Tokenizer("subKey_tokenizer")
.Filters("lowercase")
)
)
.Tokenizers(ta => ta
.NGram("subKey_tokenizer", t => t
.MinGram(1)
.MaxGram(1)
.TokenChars(new TokenChar { TokenChar.Letter, TokenChar.Whitespace })
)
)
)
)
.Mappings(ms => ms
.Map<SpecialIndex>(m => m
.Properties(p => p
.Text(s => s
.Name(x => x.subKey)
.Analyzer("subKey_analyzer")
)
)
));


Any ideas on how to resolve this? Thank you very much!



NOTE: i've seen posts saying this can be done with a filter, using missing. But as you can see from the query, i need the Query to do this, not the filter.



i've also tried the following rather than the MUST_NOT EXISTS



{
"term": { "subKey": { "value": "" }}
}


but doesn't work. I'm thinking I need another tokenizer to get this working.










share|improve this question





























    0















    I'm using Elastic 6.5 .



    I need to include an empty string search with one of the criteria i'm passing.



    primaryKey = 1, 2, 3



    subKey = "" or subKey = "A" along with a bunch of other criteria.



    I've been unable to get the record that has the empty subKey.



    i've tried using the MUST_NOT EXISTS but it doesn't fetch the record in question.



    So below should return any records that have primarykey of 1, 2, or 3. and subKey of 'A' or Empty String. Filtered by the Date provided. I get all the records Except the record where the subKey is blank.



    so i've tried this:



    {
    "size": 200, "from": 0,
    "query": {
    "bool": {
    "must": [{
    "bool": {
    "should": [{ "terms": {"primaryKey": [1,2,3] }}]
    }
    },
    {
    "bool": {
    "should": [
    {"match": {"subKey": "A"}},
    {
    "bool" : {
    "must_not": [{ "exists": { "field": "subKey"} }]
    }
    }
    ]
    }
    }],
    "filter": [{"range": {"startdate": {"lte": "2018-11-01"}}}]
    }
    }
    }


    The subkey field is special.. where it's actually searched by LETTER. But i don't think that effects anything.. but here is the NEST coding i have for that index.



    new CreateIndexDescriptor("SpecialIndex").Settings(s => s
    .Analysis(a => a
    .Analyzers(aa => aa
    .Custom("subKey_analyzer", ma => ma
    .Tokenizer("subKey_tokenizer")
    .Filters("lowercase")
    )
    )
    .Tokenizers(ta => ta
    .NGram("subKey_tokenizer", t => t
    .MinGram(1)
    .MaxGram(1)
    .TokenChars(new TokenChar { TokenChar.Letter, TokenChar.Whitespace })
    )
    )
    )
    )
    .Mappings(ms => ms
    .Map<SpecialIndex>(m => m
    .Properties(p => p
    .Text(s => s
    .Name(x => x.subKey)
    .Analyzer("subKey_analyzer")
    )
    )
    ));


    Any ideas on how to resolve this? Thank you very much!



    NOTE: i've seen posts saying this can be done with a filter, using missing. But as you can see from the query, i need the Query to do this, not the filter.



    i've also tried the following rather than the MUST_NOT EXISTS



    {
    "term": { "subKey": { "value": "" }}
    }


    but doesn't work. I'm thinking I need another tokenizer to get this working.










    share|improve this question



























      0












      0








      0








      I'm using Elastic 6.5 .



      I need to include an empty string search with one of the criteria i'm passing.



      primaryKey = 1, 2, 3



      subKey = "" or subKey = "A" along with a bunch of other criteria.



      I've been unable to get the record that has the empty subKey.



      i've tried using the MUST_NOT EXISTS but it doesn't fetch the record in question.



      So below should return any records that have primarykey of 1, 2, or 3. and subKey of 'A' or Empty String. Filtered by the Date provided. I get all the records Except the record where the subKey is blank.



      so i've tried this:



      {
      "size": 200, "from": 0,
      "query": {
      "bool": {
      "must": [{
      "bool": {
      "should": [{ "terms": {"primaryKey": [1,2,3] }}]
      }
      },
      {
      "bool": {
      "should": [
      {"match": {"subKey": "A"}},
      {
      "bool" : {
      "must_not": [{ "exists": { "field": "subKey"} }]
      }
      }
      ]
      }
      }],
      "filter": [{"range": {"startdate": {"lte": "2018-11-01"}}}]
      }
      }
      }


      The subkey field is special.. where it's actually searched by LETTER. But i don't think that effects anything.. but here is the NEST coding i have for that index.



      new CreateIndexDescriptor("SpecialIndex").Settings(s => s
      .Analysis(a => a
      .Analyzers(aa => aa
      .Custom("subKey_analyzer", ma => ma
      .Tokenizer("subKey_tokenizer")
      .Filters("lowercase")
      )
      )
      .Tokenizers(ta => ta
      .NGram("subKey_tokenizer", t => t
      .MinGram(1)
      .MaxGram(1)
      .TokenChars(new TokenChar { TokenChar.Letter, TokenChar.Whitespace })
      )
      )
      )
      )
      .Mappings(ms => ms
      .Map<SpecialIndex>(m => m
      .Properties(p => p
      .Text(s => s
      .Name(x => x.subKey)
      .Analyzer("subKey_analyzer")
      )
      )
      ));


      Any ideas on how to resolve this? Thank you very much!



      NOTE: i've seen posts saying this can be done with a filter, using missing. But as you can see from the query, i need the Query to do this, not the filter.



      i've also tried the following rather than the MUST_NOT EXISTS



      {
      "term": { "subKey": { "value": "" }}
      }


      but doesn't work. I'm thinking I need another tokenizer to get this working.










      share|improve this question
















      I'm using Elastic 6.5 .



      I need to include an empty string search with one of the criteria i'm passing.



      primaryKey = 1, 2, 3



      subKey = "" or subKey = "A" along with a bunch of other criteria.



      I've been unable to get the record that has the empty subKey.



      i've tried using the MUST_NOT EXISTS but it doesn't fetch the record in question.



      So below should return any records that have primarykey of 1, 2, or 3. and subKey of 'A' or Empty String. Filtered by the Date provided. I get all the records Except the record where the subKey is blank.



      so i've tried this:



      {
      "size": 200, "from": 0,
      "query": {
      "bool": {
      "must": [{
      "bool": {
      "should": [{ "terms": {"primaryKey": [1,2,3] }}]
      }
      },
      {
      "bool": {
      "should": [
      {"match": {"subKey": "A"}},
      {
      "bool" : {
      "must_not": [{ "exists": { "field": "subKey"} }]
      }
      }
      ]
      }
      }],
      "filter": [{"range": {"startdate": {"lte": "2018-11-01"}}}]
      }
      }
      }


      The subkey field is special.. where it's actually searched by LETTER. But i don't think that effects anything.. but here is the NEST coding i have for that index.



      new CreateIndexDescriptor("SpecialIndex").Settings(s => s
      .Analysis(a => a
      .Analyzers(aa => aa
      .Custom("subKey_analyzer", ma => ma
      .Tokenizer("subKey_tokenizer")
      .Filters("lowercase")
      )
      )
      .Tokenizers(ta => ta
      .NGram("subKey_tokenizer", t => t
      .MinGram(1)
      .MaxGram(1)
      .TokenChars(new TokenChar { TokenChar.Letter, TokenChar.Whitespace })
      )
      )
      )
      )
      .Mappings(ms => ms
      .Map<SpecialIndex>(m => m
      .Properties(p => p
      .Text(s => s
      .Name(x => x.subKey)
      .Analyzer("subKey_analyzer")
      )
      )
      ));


      Any ideas on how to resolve this? Thank you very much!



      NOTE: i've seen posts saying this can be done with a filter, using missing. But as you can see from the query, i need the Query to do this, not the filter.



      i've also tried the following rather than the MUST_NOT EXISTS



      {
      "term": { "subKey": { "value": "" }}
      }


      but doesn't work. I'm thinking I need another tokenizer to get this working.







      elasticsearch nest






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 '18 at 18:13







      user1161137

















      asked Nov 20 '18 at 16:48









      user1161137user1161137

      4141417




      4141417
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Ok, I managed to fix this by using Multi-fields. This is what i did.



          Changed the Mappings to this:



                            .Mappings(ms => ms
          .Map<SpecialIndex>(m => m
          .Properties(p => p
          .Text(s => s
          .Name(x => x.subKey)
          .Fields(ff => ff
          .Text(tt => tt
          .Name("subKey")
          .Analyzer("subKey_analyzer")
          )
          .Keyword(k => k
          .Name("keyword")
          .IgnoreAbove(5)
          )
          )
          )
          )
          ));


          then i changed my query BOOL piece to this:



                      "bool": {
          "should": [{
          "match": {
          "subKey.subKey": {
          "query": "A"
          }
          }
          },
          {
          "term": {
          "subKey.keyword": {
          "value": ""
          }
          }
          }]
          }


          what i don't really like about this is that i think Elastic is creating an additional field just to find EMPTY strings of the same field. That really doesn't seem ideal.



          Anyone have another suggestion that would be great!



          [UPDATE] The NEST implementation needs to use SUFFIX to access the multi-fields.



          .Bool(bb => bb
          .Should(bbs => bbs
          .Match(m => m.Field(f => f.subKey.Suffix("subKey")).Query(search.subKey)),
          bbs => bbs
          .Term(t => t.Verbatim().Field(f => f.subKey.Suffix("keyword")).Value(string.Empty)))





          share|improve this answer


























          • Were you writing your original query with NEST? If so, did you look at the query generated? Searching for an empty string in a term query will trigger conditionless behaviour, so it may be worth looking at this. See second part of answer: stackoverflow.com/a/37714606/1831

            – Russ Cam
            Nov 20 '18 at 21:53











          • Ok, there is a problem above... my NEST is not producing the BOOL piece like i mentioned. Yes, changing the DSL works but not what i had in the NEST. So i'm trying to figure out how to specify the {"term": { "subKey.keyword": { "value": "" }} right now it is doing {"term": {"subKey" : {"value" : ""}} in NEST.

            – user1161137
            Nov 26 '18 at 16:53













          • Ok, wasn't using Suffix. @RussCam But to answer your question regarding conditionless behavior, the NEST does 'now' create a dsl query that searches the empty string. confirmed the query generated by NEST. And it does return the empty records as intended. Maybe the Verbatim handles the problem you mention? Is there a different way to handle this?

            – user1161137
            Nov 26 '18 at 17:08













          • Since no one is posting an alternative to this solution, i'll post this one as the solution.

            – user1161137
            Nov 26 '18 at 22:40











          • .Verbatim() overrides the conditionless behaviour on queries, to allow you to perform a term query with an empty string

            – Russ Cam
            Nov 26 '18 at 23:00











          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%2f53397743%2fempty-string-elastic-search%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









          0














          Ok, I managed to fix this by using Multi-fields. This is what i did.



          Changed the Mappings to this:



                            .Mappings(ms => ms
          .Map<SpecialIndex>(m => m
          .Properties(p => p
          .Text(s => s
          .Name(x => x.subKey)
          .Fields(ff => ff
          .Text(tt => tt
          .Name("subKey")
          .Analyzer("subKey_analyzer")
          )
          .Keyword(k => k
          .Name("keyword")
          .IgnoreAbove(5)
          )
          )
          )
          )
          ));


          then i changed my query BOOL piece to this:



                      "bool": {
          "should": [{
          "match": {
          "subKey.subKey": {
          "query": "A"
          }
          }
          },
          {
          "term": {
          "subKey.keyword": {
          "value": ""
          }
          }
          }]
          }


          what i don't really like about this is that i think Elastic is creating an additional field just to find EMPTY strings of the same field. That really doesn't seem ideal.



          Anyone have another suggestion that would be great!



          [UPDATE] The NEST implementation needs to use SUFFIX to access the multi-fields.



          .Bool(bb => bb
          .Should(bbs => bbs
          .Match(m => m.Field(f => f.subKey.Suffix("subKey")).Query(search.subKey)),
          bbs => bbs
          .Term(t => t.Verbatim().Field(f => f.subKey.Suffix("keyword")).Value(string.Empty)))





          share|improve this answer


























          • Were you writing your original query with NEST? If so, did you look at the query generated? Searching for an empty string in a term query will trigger conditionless behaviour, so it may be worth looking at this. See second part of answer: stackoverflow.com/a/37714606/1831

            – Russ Cam
            Nov 20 '18 at 21:53











          • Ok, there is a problem above... my NEST is not producing the BOOL piece like i mentioned. Yes, changing the DSL works but not what i had in the NEST. So i'm trying to figure out how to specify the {"term": { "subKey.keyword": { "value": "" }} right now it is doing {"term": {"subKey" : {"value" : ""}} in NEST.

            – user1161137
            Nov 26 '18 at 16:53













          • Ok, wasn't using Suffix. @RussCam But to answer your question regarding conditionless behavior, the NEST does 'now' create a dsl query that searches the empty string. confirmed the query generated by NEST. And it does return the empty records as intended. Maybe the Verbatim handles the problem you mention? Is there a different way to handle this?

            – user1161137
            Nov 26 '18 at 17:08













          • Since no one is posting an alternative to this solution, i'll post this one as the solution.

            – user1161137
            Nov 26 '18 at 22:40











          • .Verbatim() overrides the conditionless behaviour on queries, to allow you to perform a term query with an empty string

            – Russ Cam
            Nov 26 '18 at 23:00
















          0














          Ok, I managed to fix this by using Multi-fields. This is what i did.



          Changed the Mappings to this:



                            .Mappings(ms => ms
          .Map<SpecialIndex>(m => m
          .Properties(p => p
          .Text(s => s
          .Name(x => x.subKey)
          .Fields(ff => ff
          .Text(tt => tt
          .Name("subKey")
          .Analyzer("subKey_analyzer")
          )
          .Keyword(k => k
          .Name("keyword")
          .IgnoreAbove(5)
          )
          )
          )
          )
          ));


          then i changed my query BOOL piece to this:



                      "bool": {
          "should": [{
          "match": {
          "subKey.subKey": {
          "query": "A"
          }
          }
          },
          {
          "term": {
          "subKey.keyword": {
          "value": ""
          }
          }
          }]
          }


          what i don't really like about this is that i think Elastic is creating an additional field just to find EMPTY strings of the same field. That really doesn't seem ideal.



          Anyone have another suggestion that would be great!



          [UPDATE] The NEST implementation needs to use SUFFIX to access the multi-fields.



          .Bool(bb => bb
          .Should(bbs => bbs
          .Match(m => m.Field(f => f.subKey.Suffix("subKey")).Query(search.subKey)),
          bbs => bbs
          .Term(t => t.Verbatim().Field(f => f.subKey.Suffix("keyword")).Value(string.Empty)))





          share|improve this answer


























          • Were you writing your original query with NEST? If so, did you look at the query generated? Searching for an empty string in a term query will trigger conditionless behaviour, so it may be worth looking at this. See second part of answer: stackoverflow.com/a/37714606/1831

            – Russ Cam
            Nov 20 '18 at 21:53











          • Ok, there is a problem above... my NEST is not producing the BOOL piece like i mentioned. Yes, changing the DSL works but not what i had in the NEST. So i'm trying to figure out how to specify the {"term": { "subKey.keyword": { "value": "" }} right now it is doing {"term": {"subKey" : {"value" : ""}} in NEST.

            – user1161137
            Nov 26 '18 at 16:53













          • Ok, wasn't using Suffix. @RussCam But to answer your question regarding conditionless behavior, the NEST does 'now' create a dsl query that searches the empty string. confirmed the query generated by NEST. And it does return the empty records as intended. Maybe the Verbatim handles the problem you mention? Is there a different way to handle this?

            – user1161137
            Nov 26 '18 at 17:08













          • Since no one is posting an alternative to this solution, i'll post this one as the solution.

            – user1161137
            Nov 26 '18 at 22:40











          • .Verbatim() overrides the conditionless behaviour on queries, to allow you to perform a term query with an empty string

            – Russ Cam
            Nov 26 '18 at 23:00














          0












          0








          0







          Ok, I managed to fix this by using Multi-fields. This is what i did.



          Changed the Mappings to this:



                            .Mappings(ms => ms
          .Map<SpecialIndex>(m => m
          .Properties(p => p
          .Text(s => s
          .Name(x => x.subKey)
          .Fields(ff => ff
          .Text(tt => tt
          .Name("subKey")
          .Analyzer("subKey_analyzer")
          )
          .Keyword(k => k
          .Name("keyword")
          .IgnoreAbove(5)
          )
          )
          )
          )
          ));


          then i changed my query BOOL piece to this:



                      "bool": {
          "should": [{
          "match": {
          "subKey.subKey": {
          "query": "A"
          }
          }
          },
          {
          "term": {
          "subKey.keyword": {
          "value": ""
          }
          }
          }]
          }


          what i don't really like about this is that i think Elastic is creating an additional field just to find EMPTY strings of the same field. That really doesn't seem ideal.



          Anyone have another suggestion that would be great!



          [UPDATE] The NEST implementation needs to use SUFFIX to access the multi-fields.



          .Bool(bb => bb
          .Should(bbs => bbs
          .Match(m => m.Field(f => f.subKey.Suffix("subKey")).Query(search.subKey)),
          bbs => bbs
          .Term(t => t.Verbatim().Field(f => f.subKey.Suffix("keyword")).Value(string.Empty)))





          share|improve this answer















          Ok, I managed to fix this by using Multi-fields. This is what i did.



          Changed the Mappings to this:



                            .Mappings(ms => ms
          .Map<SpecialIndex>(m => m
          .Properties(p => p
          .Text(s => s
          .Name(x => x.subKey)
          .Fields(ff => ff
          .Text(tt => tt
          .Name("subKey")
          .Analyzer("subKey_analyzer")
          )
          .Keyword(k => k
          .Name("keyword")
          .IgnoreAbove(5)
          )
          )
          )
          )
          ));


          then i changed my query BOOL piece to this:



                      "bool": {
          "should": [{
          "match": {
          "subKey.subKey": {
          "query": "A"
          }
          }
          },
          {
          "term": {
          "subKey.keyword": {
          "value": ""
          }
          }
          }]
          }


          what i don't really like about this is that i think Elastic is creating an additional field just to find EMPTY strings of the same field. That really doesn't seem ideal.



          Anyone have another suggestion that would be great!



          [UPDATE] The NEST implementation needs to use SUFFIX to access the multi-fields.



          .Bool(bb => bb
          .Should(bbs => bbs
          .Match(m => m.Field(f => f.subKey.Suffix("subKey")).Query(search.subKey)),
          bbs => bbs
          .Term(t => t.Verbatim().Field(f => f.subKey.Suffix("keyword")).Value(string.Empty)))






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 26 '18 at 17:06

























          answered Nov 20 '18 at 19:40









          user1161137user1161137

          4141417




          4141417













          • Were you writing your original query with NEST? If so, did you look at the query generated? Searching for an empty string in a term query will trigger conditionless behaviour, so it may be worth looking at this. See second part of answer: stackoverflow.com/a/37714606/1831

            – Russ Cam
            Nov 20 '18 at 21:53











          • Ok, there is a problem above... my NEST is not producing the BOOL piece like i mentioned. Yes, changing the DSL works but not what i had in the NEST. So i'm trying to figure out how to specify the {"term": { "subKey.keyword": { "value": "" }} right now it is doing {"term": {"subKey" : {"value" : ""}} in NEST.

            – user1161137
            Nov 26 '18 at 16:53













          • Ok, wasn't using Suffix. @RussCam But to answer your question regarding conditionless behavior, the NEST does 'now' create a dsl query that searches the empty string. confirmed the query generated by NEST. And it does return the empty records as intended. Maybe the Verbatim handles the problem you mention? Is there a different way to handle this?

            – user1161137
            Nov 26 '18 at 17:08













          • Since no one is posting an alternative to this solution, i'll post this one as the solution.

            – user1161137
            Nov 26 '18 at 22:40











          • .Verbatim() overrides the conditionless behaviour on queries, to allow you to perform a term query with an empty string

            – Russ Cam
            Nov 26 '18 at 23:00



















          • Were you writing your original query with NEST? If so, did you look at the query generated? Searching for an empty string in a term query will trigger conditionless behaviour, so it may be worth looking at this. See second part of answer: stackoverflow.com/a/37714606/1831

            – Russ Cam
            Nov 20 '18 at 21:53











          • Ok, there is a problem above... my NEST is not producing the BOOL piece like i mentioned. Yes, changing the DSL works but not what i had in the NEST. So i'm trying to figure out how to specify the {"term": { "subKey.keyword": { "value": "" }} right now it is doing {"term": {"subKey" : {"value" : ""}} in NEST.

            – user1161137
            Nov 26 '18 at 16:53













          • Ok, wasn't using Suffix. @RussCam But to answer your question regarding conditionless behavior, the NEST does 'now' create a dsl query that searches the empty string. confirmed the query generated by NEST. And it does return the empty records as intended. Maybe the Verbatim handles the problem you mention? Is there a different way to handle this?

            – user1161137
            Nov 26 '18 at 17:08













          • Since no one is posting an alternative to this solution, i'll post this one as the solution.

            – user1161137
            Nov 26 '18 at 22:40











          • .Verbatim() overrides the conditionless behaviour on queries, to allow you to perform a term query with an empty string

            – Russ Cam
            Nov 26 '18 at 23:00

















          Were you writing your original query with NEST? If so, did you look at the query generated? Searching for an empty string in a term query will trigger conditionless behaviour, so it may be worth looking at this. See second part of answer: stackoverflow.com/a/37714606/1831

          – Russ Cam
          Nov 20 '18 at 21:53





          Were you writing your original query with NEST? If so, did you look at the query generated? Searching for an empty string in a term query will trigger conditionless behaviour, so it may be worth looking at this. See second part of answer: stackoverflow.com/a/37714606/1831

          – Russ Cam
          Nov 20 '18 at 21:53













          Ok, there is a problem above... my NEST is not producing the BOOL piece like i mentioned. Yes, changing the DSL works but not what i had in the NEST. So i'm trying to figure out how to specify the {"term": { "subKey.keyword": { "value": "" }} right now it is doing {"term": {"subKey" : {"value" : ""}} in NEST.

          – user1161137
          Nov 26 '18 at 16:53







          Ok, there is a problem above... my NEST is not producing the BOOL piece like i mentioned. Yes, changing the DSL works but not what i had in the NEST. So i'm trying to figure out how to specify the {"term": { "subKey.keyword": { "value": "" }} right now it is doing {"term": {"subKey" : {"value" : ""}} in NEST.

          – user1161137
          Nov 26 '18 at 16:53















          Ok, wasn't using Suffix. @RussCam But to answer your question regarding conditionless behavior, the NEST does 'now' create a dsl query that searches the empty string. confirmed the query generated by NEST. And it does return the empty records as intended. Maybe the Verbatim handles the problem you mention? Is there a different way to handle this?

          – user1161137
          Nov 26 '18 at 17:08







          Ok, wasn't using Suffix. @RussCam But to answer your question regarding conditionless behavior, the NEST does 'now' create a dsl query that searches the empty string. confirmed the query generated by NEST. And it does return the empty records as intended. Maybe the Verbatim handles the problem you mention? Is there a different way to handle this?

          – user1161137
          Nov 26 '18 at 17:08















          Since no one is posting an alternative to this solution, i'll post this one as the solution.

          – user1161137
          Nov 26 '18 at 22:40





          Since no one is posting an alternative to this solution, i'll post this one as the solution.

          – user1161137
          Nov 26 '18 at 22:40













          .Verbatim() overrides the conditionless behaviour on queries, to allow you to perform a term query with an empty string

          – Russ Cam
          Nov 26 '18 at 23:00





          .Verbatim() overrides the conditionless behaviour on queries, to allow you to perform a term query with an empty string

          – Russ Cam
          Nov 26 '18 at 23:00




















          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%2f53397743%2fempty-string-elastic-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







          Popular posts from this blog

          How to change which sound is reproduced for terminal bell?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

          Can I use Tabulator js library in my java Spring + Thymeleaf project?