Note that there are some explanatory texts on larger screens.

plurals
  1. POQueries without extra index in GAE
    primarykey
    data
    text
    <p>In a Google App Engine Application (GAE/Java) I have a class like this one:</p> <pre><code>public class Person{ private int born; private String sex; private List&lt;String&gt; likes; //some other fields ... } </code></pre> <p>I need that the user of the application can search on different fields. For example the user may ask for searching:</p> <ol> <li>All the people who were born after 1975 and like potatoes and fish</li> <li>All the women who were born before 1980 and like carrots</li> </ol> <p>I mean, the queries may have a variable number of filters. <strong>It is very important that the query doesn't need an extra index</strong>, so I've read the documentation and it says that queries using only equality don't need an extra index.</p> <p>So I have thought of using IN operator (because it is coverted to equals operator) like this:</p> <pre><code>select from Person where likes IN ("potatoes", "fish") AND born IN (1975,1976....2011) select from Person where sex = 'female' AND likes = "carrots" AND born IN (1900,1901....1980) </code></pre> <p>The problem is that as it is stated in the documentation:</p> <blockquote> <p>The IN operator also performs multiple queries, one for each item in the provided list value where all other filters are the same and the IN filter is replaced with an equal-to filter. The results are merged, in the order of the items in the list. If a query has more than one IN filter, the query is performed as multiple queries, one for each combination of values in the IN filters.</p> <p>A single query containing NOT_EQUAL or IN operators <strong>is limited to 30 sub-queries.</strong></p> </blockquote> <p>The user won't user many fields, typically at most 3 in the same query (though there are many fields that can be used), but I need to search for users in any range of age. So this approach will end in the limitation of the 30 sub-queries.</p> <p>How can I design a solution which solves this problem?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload