Search code examples
javagoogle-app-enginegoogle-search-api

Why doesn't this Google AppEngine Search API query find any results?


I'm trying to search indexed documents with this query, and it is turning up 0 results, even though the items exist. Why?

Keyword search on the description field and search by year works. 'sbu' is an atom field.

Log

INFO: Searching with query:  year:( 2013  )  sbu:(Special Bictums Unit) 
Oct 31, 2013 8:36:17 PM com.mwv.pic.service.SearchService search
INFO: results.size:0

INFO: Searching with query:  year:( 2013  )  sbu:("Special Bictums Unit") 
INFO: results.size:0

INFO: Searching with query:  sbu:("Special Bictums Unit") 
INFO: results.size:0

INFO: Searching with query:  sbu:"Special Bictums Unit" 
INFO: results.size:0

INFO: Searching with query:  year:( 2013  ) 
INFO: results.size:3

Code

    log.info("Searching with query: " + q);
    try {
        Results<ScoredDocument> results = getIndex().search(q);
        log.info("results.size:"+results.getNumberReturned());

Indexes in Admin Console

Imgur

Reference

https://developers.google.com/appengine/docs/java/search/query_strings

Indexing values

Nov 04, 2013 5:55:44 PM com.mwv.pic.service.SearchService indexStudy
INFO: add field sbu:'Special Bictums Unit'

builder.addField(Field.newBuilder().setName("sbu").setAtom(sbu));
log.info("add field sbu:'"+sbu+"'");

Solution

  • Searching for atom fields with blanks in them currently does not work on the Java dev server; but I believe it works in production, and on the Python dev server.

    The recommended query syntax is: [sbu:"Special Bictums Unit"] (without the square brackets).