Searching for empty string using queryString

Hello,
I have very specific case with the queryString filter
I want to include record that is empty string - “”, but mongo does not return it with the aggregation

          {
              queryString: {
                defaultPath: `geo_locations.country,
                query: '"United States of America" OR ""',
              },
            },

I can retrieve records with country USA, but not those that are empty string.
Is it possible to search for those as well ?

Screenshot 2023-12-06 at 1.09.00

Hey @Ivan_Kraev , there are a few options to search for empty strings in Atlas Search. I’d suggest using the compound.mustNot with the wildcard operator

{
  compound: {
    should: [
      {
        compound: {
          mustNot: {
            wildcard: {
              query: '*',
              path: 'geo_locations.country',
              allowAnalyzedField: true
            }
          },
          must: {
            queryString: {
              defaultPath: 'geo_locations.country',
              query: 'United States of America'
            }
          }
        }
      }
    ]
  }
}
2 Likes