2

Suppose I have an optional field called 'xyz' in the list of documents I've indexed in CloudSearch.

How do I query CloudSearch so that it returns only those documents that contain 'xyz'?

If I know up front, that it's a positive integer, I can probably do something like this to get the required list: q=xyz:[0,}&q.parser=structured

But how do I do it if 'xyz' stores some other type like a string or a list of ints/strings etc.,?

BTW, I've used Solr before, and there, I could simply do q=xyz:* to achieve this. Does CloudSearch support such regular expressions?

user2602740
  • 637
  • 6
  • 17
  • Related: http://stackoverflow.com/questions/26591773/amazon-cloudsearch-filter-if-exists – shj Dec 08 '14 at 15:43

1 Answers1

1

You can query for non empty values in a field using * operator, in your case its going to be xyz:* This will only work if you are using Lucene parser for your query to CloudSearch.

  • Query Parser is attribute as "queryParser" in search api, example code: $result = $this->client->search(array( 'query' => $str, //'queryParser' => 'simple|structured|lucene|dismax', 'queryParser' => 'lucene', 'size' => 100, 'return' => '_score,_all_fields' )); – Muhammad Manazar Sep 16 '15 at 22:00