Home > OS >  Is there a way to query Google AppEngine Search API for documents where a field contains at least on
Is there a way to query Google AppEngine Search API for documents where a field contains at least on

Time:12-21

For instance, suppose we have 3 zoos in a Datastore.

  • (id=23, animals=["Horse", "Elephant", "Giraffe"]
  • (id=42, animals=["Alpaca", "Turtle", "Panda"]
  • (id=77, animals=["Wolf", "Alligator", "Tiger"]

I want to query for zoos that contain AT LEAST ONE of the following animals: "Horse", "Elephant", "Alpaca". I need this query to return zoos 23 and 42, but not zoo 77.

Tried so far:

  • animals: "Horse" OR animals: "Elephant" OR animals: "Alpaca" works for smaller queries, but in the actual real life case queries constructed like that easily exceed 2000 bytes query size limit imposed by Google.
  • ("Horse" OR "Elephant" OR "Alpaca") IN animals returns 0 results.
  • animals IN ("Horse" OR "Elephant" OR "Alpaca") returns 0 results.

Restriction: must be a fixed amount of queries, ideally a single one. A solution where the amount of queries grows with the amount of search items won't scale and will easily result in hundreds of Datastore queries per single HTTP request from a user. That is unacceptible.

Any suggestions how to achieve this?

CodePudding user response:

animals: ("Horse" OR "Elephant" OR "Alpaca")
  • Related