# Package com.google.appengine.api.prospectivesearch.dev

# Implementation Notes

See: Description

- Class Summary
  Class | Description
  --- | ---
  LocalSearchService | Local Prospective Search service using in-memory O(n) subscription management.
  ProspectiveSearchReservedKinds | Exposes constants for reserved datastore kinds used by the local datastore service.
  QueryEvaluator | The QueryEvaluator class performs a full visit of the query tree, dispatching leaf evaluations to the QueryEngine.

## Package com.google.appengine.api.prospectivesearch.dev Description

# Implementation Notes

- Matching entity properties with string values is done with substring matching, not against tokens.
- Numeric limits in the public API that are specified as long are truncated to int. E.g. in the listTopics method.

## Python language diffs

- Empty queries invalid; python accepts.
- Curly braces as grouping operator are not supported; python accepts.
- Unbalanced quotes considered invalid; python accepts. Quotes treated as term breaks. python considers part of word when inline with other characters.
- Number ranges require whitespace around elipsis; python does not.

## BNF for VanillaQuery.jj

### TOKENS

    <DEFAULT> SKIP : {
    " "
    | "\t"
    | "\n"
    | "\r"
    | "\r\n"
    }
    <DEFAULT> TOKEN : {
    <DOT: ".">
    | <COLON: ":">
    | <EQUALS: "=">
    | <EQUALSEQUALS: "==">
    | <LPAREN: "(">
    | <RPAREN: ")">
    | <AND: "AND">
    | <OR: "OR" | "|">
    | <NOT: "-" | "NOT">
    | <LESS: "<">
    | <GREATER: ">">
    | <LESSOREQUALS: "<=" | "=<">
    | <GREATEROREQUALS: ">=" | "=>">
    | <#DIGIT: ["0"-"9"]>
    | <#DIGITS: (<DIGIT>)+>
    | <NUMBER: ("-" | "+")? (<DIGITS> (<DOT> <DIGITS>)? | <DOT> <DIGITS>)>
    | <ELIPSIS: ".." | "...">
    | <NUMBERRANGE: <NUMBER> <ELIPSIS> <NUMBER>>
    | <#NOTSPECIAL: ~[":","=","(",")","{","}","|","-","<",">"," ","\""]>
    | <TEXT: <NOTSPECIAL> (<NOTSPECIAL> | "-")*>
    | <STRING_LITERAL: "\"" (~["\""])* "\"">
    }

## NON-TERMINALS

    /**
     * Root production for syntax like (x AND y OR b AND (a b)), terminals
     * handled by QueryTerm().
     */
QueryExpr | ::= | QueryTerm ( <AND> QueryTerm | <OR> QueryTerm | QueryTerm )* <EOF>
    /**
     * Production for query terms, e.g.:
     *
     * -a
     * a:b
     * (a:b -c)
     */
QueryTerm | ::= | <NOT> QueryTerm
| | | <TEXT> ( Op QueryValue )?
| | | <LPAREN> QueryExpr <RPAREN>
    /**
     * Production for query operator, e.g. the ":" in:
     *
     *  a:b
     * where ":" may also be: =, ==, <, <=, >, >=.
     */
Op | ::= | ( <COLON> | <EQUALS> | <EQUALSEQUALS> | <LESS> | <GREATER> | <LESSOREQUALS> | <GREATEROREQUALS> )
    /**
     * Production to recognize the query text, which may also be a number
     * range or a nested boolean query just on that field, e.g.:
     *
     *   a:b AND a:c
     *
     * may be:
     *
     *   a:(b AND c)
     */
QueryValue | ::= | <TEXT>
| | | <STRING_LITERAL>
| | | ( <NUMBER> ( <ELIPSIS> <NUMBER> )? )
| | | <LPAREN> FieldQueryExpr <RPAREN>
    /**
     * Production to recognize the inner field query text, otherwise
     * similar to QueryExpr.
     */
FieldQueryExpr | ::= | FieldTerm ( <AND> FieldTerm | <OR> FieldTerm | FieldTerm )*
    /**
     * Production to recognize the inner field terms, otherwise
     * similar to QueryTerm.
     */
FieldTerm | ::= | <NOT> FieldTerm
| | | <TEXT>
| | | <STRING_LITERAL>
| | | <LPAREN> FieldQueryExpr <RPAREN>