2

Rather simple question here. Using CloudSearch, how do I find an object that does NOT have a certain key/property defined.

eg. I have been storing Car objects all along without indexing their price. Now I have began indexing Car objects with their msrp... how do I find the Car objects stored without any indexed price?

(and price:null) (and price:undefined) and other similar 'falsy' statements and their stringified permutations all do not work.

I am using AWS sdk in Node.js.

TIA!

Niko

nemo
  • 593
  • 2
  • 8
  • 22

1 Answers1

0

The option that will work without any reindexing is a range search like

(NOT (range field=price [0,}))

which matches cars with a price that is not between 0 and infinity (eg ones with no price). See this answer for a discussion of other options.

Side note: I get the impression that you may be using CloudSearch to store your data. If so, I would consider using a datastore (which are designed to store data) rather than CloudSearch (which is a search engine). For one, it'll make this sort of query much easier.

Community
  • 1
  • 1
alexroussos
  • 2,671
  • 1
  • 25
  • 38
  • 1
    hey thanks for the suggestion! just fyi, I am not using cloudsearch as a datastore. it just also holds the query-able fields of our data. – nemo Sep 21 '15 at 21:48
  • Ok cool, that means you can consider some of the other options. I think setting things without a price to some sentinel value like -1 might be worth considering. – alexroussos Sep 21 '15 at 22:09
  • 1
    well yes and no... the cars without a price dont have a price because we did not care about price before (in reality, cars always have prices unfortunately :( ) – nemo Sep 22 '15 at 18:08
  • Sure but you can easily test for that in whatever language you're using (node.js)? – alexroussos Sep 22 '15 at 19:26