<p dir="auto">Hello,</p>
<p dir="auto">I've been trying to find all documents that contains a field with an empty string value (<code class="notranslate">_textContent</code>) inside my index using the <code class="notranslate">missing</code> filter. But I think that this filter doesn't treat empty strings as a null value.</p>
<p dir="auto">Is this a bug, or the intended behavior for this filter? If it is like this by design, may I suggest adding an <code class="notranslate">empty</code> filter, if that's even possible?</p>
<p dir="auto">As a plus, I'll post the mapping that I'm currently using, the document that contains the empty string field and the query that I'm trying to run:</p>
<p dir="auto">Mapping:</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;documents&quot;: {
    &quot;mappings&quot;: {
      &quot;document&quot;: {
        &quot;properties&quot;: {
          &quot;_contratante&quot;: {
            &quot;type&quot;: &quot;string&quot;
          },
          &quot;_dateFields&quot;: {
            &quot;type&quot;: &quot;nested&quot;,
            &quot;properties&quot;: {
              &quot;id&quot;: {
                &quot;type&quot;: &quot;string&quot;,
                &quot;index&quot;: &quot;not_analyzed&quot;
              },
              &quot;value&quot;: {
                &quot;type&quot;: &quot;date&quot;,
                &quot;format&quot;: &quot;dateOptionalTime&quot;
              }
            }
          },
          &quot;_indexadoPor&quot;: {
            &quot;type&quot;: &quot;string&quot;
          },
          &quot;_textContent&quot;: {
            &quot;type&quot;: &quot;string&quot;
          },
          &quot;_textFields&quot;: {
            &quot;type&quot;: &quot;nested&quot;,
            &quot;properties&quot;: {
              &quot;id&quot;: {
                &quot;type&quot;: &quot;string&quot;,
                &quot;index&quot;: &quot;not_analyzed&quot;
              },
              &quot;value&quot;: {
                &quot;type&quot;: &quot;string&quot;
              }
            }
          },
          &quot;_tipoDocumento&quot;: {
            &quot;type&quot;: &quot;string&quot;
          }
        }
      }
    }
  }
}"><pre class="notranslate">{
  <span class="pl-ent">"documents"</span>: {
    <span class="pl-ent">"mappings"</span>: {
      <span class="pl-ent">"document"</span>: {
        <span class="pl-ent">"properties"</span>: {
          <span class="pl-ent">"_contratante"</span>: {
            <span class="pl-ent">"type"</span>: <span class="pl-s"><span class="pl-pds">"</span>string<span class="pl-pds">"</span></span>
          },
          <span class="pl-ent">"_dateFields"</span>: {
            <span class="pl-ent">"type"</span>: <span class="pl-s"><span class="pl-pds">"</span>nested<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"properties"</span>: {
              <span class="pl-ent">"id"</span>: {
                <span class="pl-ent">"type"</span>: <span class="pl-s"><span class="pl-pds">"</span>string<span class="pl-pds">"</span></span>,
                <span class="pl-ent">"index"</span>: <span class="pl-s"><span class="pl-pds">"</span>not_analyzed<span class="pl-pds">"</span></span>
              },
              <span class="pl-ent">"value"</span>: {
                <span class="pl-ent">"type"</span>: <span class="pl-s"><span class="pl-pds">"</span>date<span class="pl-pds">"</span></span>,
                <span class="pl-ent">"format"</span>: <span class="pl-s"><span class="pl-pds">"</span>dateOptionalTime<span class="pl-pds">"</span></span>
              }
            }
          },
          <span class="pl-ent">"_indexadoPor"</span>: {
            <span class="pl-ent">"type"</span>: <span class="pl-s"><span class="pl-pds">"</span>string<span class="pl-pds">"</span></span>
          },
          <span class="pl-ent">"_textContent"</span>: {
            <span class="pl-ent">"type"</span>: <span class="pl-s"><span class="pl-pds">"</span>string<span class="pl-pds">"</span></span>
          },
          <span class="pl-ent">"_textFields"</span>: {
            <span class="pl-ent">"type"</span>: <span class="pl-s"><span class="pl-pds">"</span>nested<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"properties"</span>: {
              <span class="pl-ent">"id"</span>: {
                <span class="pl-ent">"type"</span>: <span class="pl-s"><span class="pl-pds">"</span>string<span class="pl-pds">"</span></span>,
                <span class="pl-ent">"index"</span>: <span class="pl-s"><span class="pl-pds">"</span>not_analyzed<span class="pl-pds">"</span></span>
              },
              <span class="pl-ent">"value"</span>: {
                <span class="pl-ent">"type"</span>: <span class="pl-s"><span class="pl-pds">"</span>string<span class="pl-pds">"</span></span>
              }
            }
          },
          <span class="pl-ent">"_tipoDocumento"</span>: {
            <span class="pl-ent">"type"</span>: <span class="pl-s"><span class="pl-pds">"</span>string<span class="pl-pds">"</span></span>
          }
        }
      }
    }
  }
}</pre></div>
<p dir="auto">Document:</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;_index&quot;: &quot;documents&quot;,
  &quot;_type&quot;: &quot;document&quot;,
  &quot;_id&quot;: &quot;xxx&quot;,
  &quot;_version&quot;: 1,
  &quot;found&quot;: true,
  &quot;_source&quot;: {
    &quot;_id&quot;: &quot;xxx&quot;,
    &quot;_contratante&quot;: &quot;xxx&quot;,
    &quot;_tipoDocumento&quot;: &quot;xxx&quot;,
    &quot;_indexadoPor&quot;: &quot;xxx&quot;,
    &quot;_dateFields&quot;: [
      {
        &quot;id&quot;: &quot;538730ece4b0d13600208d7a:2&quot;,
        &quot;value&quot;: 1404183600000
      }
    ],
    &quot;_textFields&quot;: [
      {
        &quot;id&quot;: &quot;538730ece4b0d13600208d7a:0&quot;,
        &quot;value&quot;: &quot;xxx&quot;
      },
      {
        &quot;id&quot;: &quot;538730ece4b0d13600208d7a:1&quot;,
        &quot;value&quot;: &quot;xxx&quot;
      },
      {
        &quot;id&quot;: &quot;538730ece4b0d13600208d7a:3&quot;,
        &quot;value&quot;: &quot;&quot;
      },
      {
        &quot;id&quot;: &quot;538730ece4b0d13600208d7a:4&quot;,
        &quot;value&quot;: &quot;xxxx&quot;
      }
    ],
    &quot;_textContent&quot;: &quot;&quot;
  }
}"><pre class="notranslate">{
  <span class="pl-ent">"_index"</span>: <span class="pl-s"><span class="pl-pds">"</span>documents<span class="pl-pds">"</span></span>,
  <span class="pl-ent">"_type"</span>: <span class="pl-s"><span class="pl-pds">"</span>document<span class="pl-pds">"</span></span>,
  <span class="pl-ent">"_id"</span>: <span class="pl-s"><span class="pl-pds">"</span>xxx<span class="pl-pds">"</span></span>,
  <span class="pl-ent">"_version"</span>: <span class="pl-c1">1</span>,
  <span class="pl-ent">"found"</span>: <span class="pl-c1">true</span>,
  <span class="pl-ent">"_source"</span>: {
    <span class="pl-ent">"_id"</span>: <span class="pl-s"><span class="pl-pds">"</span>xxx<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"_contratante"</span>: <span class="pl-s"><span class="pl-pds">"</span>xxx<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"_tipoDocumento"</span>: <span class="pl-s"><span class="pl-pds">"</span>xxx<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"_indexadoPor"</span>: <span class="pl-s"><span class="pl-pds">"</span>xxx<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"_dateFields"</span>: [
      {
        <span class="pl-ent">"id"</span>: <span class="pl-s"><span class="pl-pds">"</span>538730ece4b0d13600208d7a:2<span class="pl-pds">"</span></span>,
        <span class="pl-ent">"value"</span>: <span class="pl-c1">1404183600000</span>
      }
    ],
    <span class="pl-ent">"_textFields"</span>: [
      {
        <span class="pl-ent">"id"</span>: <span class="pl-s"><span class="pl-pds">"</span>538730ece4b0d13600208d7a:0<span class="pl-pds">"</span></span>,
        <span class="pl-ent">"value"</span>: <span class="pl-s"><span class="pl-pds">"</span>xxx<span class="pl-pds">"</span></span>
      },
      {
        <span class="pl-ent">"id"</span>: <span class="pl-s"><span class="pl-pds">"</span>538730ece4b0d13600208d7a:1<span class="pl-pds">"</span></span>,
        <span class="pl-ent">"value"</span>: <span class="pl-s"><span class="pl-pds">"</span>xxx<span class="pl-pds">"</span></span>
      },
      {
        <span class="pl-ent">"id"</span>: <span class="pl-s"><span class="pl-pds">"</span>538730ece4b0d13600208d7a:3<span class="pl-pds">"</span></span>,
        <span class="pl-ent">"value"</span>: <span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>
      },
      {
        <span class="pl-ent">"id"</span>: <span class="pl-s"><span class="pl-pds">"</span>538730ece4b0d13600208d7a:4<span class="pl-pds">"</span></span>,
        <span class="pl-ent">"value"</span>: <span class="pl-s"><span class="pl-pds">"</span>xxxx<span class="pl-pds">"</span></span>
      }
    ],
    <span class="pl-ent">"_textContent"</span>: <span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>
  }
}</pre></div>
<p dir="auto">Query:</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;query&quot;: {
    &quot;filtered&quot;: {
      &quot;filter&quot;: {
        &quot;missing&quot;: {
          &quot;field&quot;: &quot;_textContent&quot;
        }
      }
    }
  }
}"><pre class="notranslate">{
  <span class="pl-ent">"query"</span>: {
    <span class="pl-ent">"filtered"</span>: {
      <span class="pl-ent">"filter"</span>: {
        <span class="pl-ent">"missing"</span>: {
          <span class="pl-ent">"field"</span>: <span class="pl-s"><span class="pl-pds">"</span>_textContent<span class="pl-pds">"</span></span>
        }
      }
    }
  }
}</pre></div>
<p dir="auto">Thanks a lot for the amazing tool developed here!</p>
<p dir="auto">Heya,</p>
<p dir="auto">in ES 1.2.4 i do something like this:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="curl -XPUT 'http://localhost:9200/twitter/user/kimchy' -d '{ &quot;name_test&quot; : &quot;Shay Banon&quot; }'
curl -XPUT 'http://localhost:9200/twitter/user/foo' -d '{ &quot;name_test&quot; : &quot;&quot; }'
curl -XPOST 'http://localhost:9200/_search' -d '{&quot;query&quot;:{&quot;filtered&quot;:{&quot;filter&quot;:{&quot;and&quot;:{&quot;filters&quot;:[{&quot;missing&quot;:{&quot;field&quot;: &quot;name_test&quot;}}]}}}}}'"><pre class="notranslate">curl -XPUT <span class="pl-s"><span class="pl-pds">'</span>http://localhost:9200/twitter/user/kimchy<span class="pl-pds">'</span></span> -d <span class="pl-s"><span class="pl-pds">'</span>{ "name_test" : "Shay Banon" }<span class="pl-pds">'</span></span>
curl -XPUT <span class="pl-s"><span class="pl-pds">'</span>http://localhost:9200/twitter/user/foo<span class="pl-pds">'</span></span> -d <span class="pl-s"><span class="pl-pds">'</span>{ "name_test" : "" }<span class="pl-pds">'</span></span>
curl -XPOST <span class="pl-s"><span class="pl-pds">'</span>http://localhost:9200/_search<span class="pl-pds">'</span></span> -d <span class="pl-s"><span class="pl-pds">'</span>{"query":{"filtered":{"filter":{"and":{"filters":[{"missing":{"field": "name_test"}}]}}}}}<span class="pl-pds">'</span></span></pre></div>
<p dir="auto">Filter in "nice view"</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;query&quot;: {
    &quot;filtered&quot;: {
      &quot;filter&quot;: {
        &quot;and&quot;: {
          &quot;filters&quot;: [
            {
              &quot;missing&quot;: {
                &quot;field&quot;: &quot;name_test&quot;
              }
            }
          ]
        }
      }
    }
  }
}"><pre class="notranslate">{
  <span class="pl-ent">"query"</span>: {
    <span class="pl-ent">"filtered"</span>: {
      <span class="pl-ent">"filter"</span>: {
        <span class="pl-ent">"and"</span>: {
          <span class="pl-ent">"filters"</span>: [
            {
              <span class="pl-ent">"missing"</span>: {
                <span class="pl-ent">"field"</span>: <span class="pl-s"><span class="pl-pds">"</span>name_test<span class="pl-pds">"</span></span>
              }
            }
          ]
        }
      }
    }
  }
}</pre></div>
<p dir="auto">This one gives 1 hit.</p>
<p dir="auto">In Version 1.3.2 i do the same stuff, but got 0 hits.</p>
<p dir="auto">Am I missing something? (I read the changelog, but didnt find something that could possible do this...)</p>
<p dir="auto">That happens, as i may suggest, when the field name got an underscore.<br>
Tested it with "name" then it will also give one hit.</p>
<p dir="auto">Thanks for watchin.</p>
<p dir="auto">Dominik</p>