java - GAE Search API Query with "Date = YYYY-MM-DD" returns no results -


i trying perform simple date query on google app engine using search api. trying achieve obtain list of documents have field equal date...

// prepare query string searchstring = "date = 2013-08-26"; query query = query.newbuilder().build(searchstring);  // date_search index indexspec indexspec = indexspec.newbuilder().setname("date_search").build(); index index = searchservicefactory.getsearchservice().getindex(indexspec);  // perform search results<scoreddocument> results = index.search(query); 

when run above code, no results returned. however, if change query date >= 2013-08-26 && date < 2013-08-27 instead, expected results returned. seems though date equality logic isn't working.

this list of documents in index...

docid                                   orderid     date        event_key 3d4e5691-8fb9-42de-bf09-f2303236f091    84288787    2013-08-25  641.0 7e4700fe-dee1-4579-87c5-69b1b1929f39    84288787    2013-08-25  650.0 8c9ca43d-7673-4f12-9f0b-e3328cbdaa85    84288787    2013-08-26  659.0 04fa8025-e01b-42d3-9bf9-21c3d9618ca7    84288787    2013-08-26  668.0 41465d1f-6d8a-431f-b226-141c8d72c064    84288787    2013-08-26  676.0 1ba01a6b-0890-43b3-8225-0ed196b6ee80    84288787    2013-08-27  676.0 a8ef18b1-ffa5-4823-8442-852f7142cad1    84288786    2013-08-25  633.0 

i expecting 3 documents returned date 2013-08-26. when running equality date = 2013-08-26 there no results, query date >= 2013-08-26 && date < 2013-08-27 returns expected 3 results.

the documents added index using following code...

// build date calendar calendar = calendar.getinstance(); date dateobject = calendar.gettime();  // create document builder builder = document.newbuilder(); builder.addfield(field.newbuilder().setname("event_key").setnumber(eventkey)); builder.addfield(field.newbuilder().setname("date").setdate(dateobject)); document document = builder.build();  // date_search index indexspec indexspec = indexspec.newbuilder().setname("date_search").build(); index index = searchservicefactory.getsearchservice().getindex(indexspec);  // store document index.put(document); 

according search api documentation, date fields stored , query-able yyyy-mm-dd precision(the time information stripped out when storing , querying). additionally, query on date fields documentation shows date equality queries supported.

could please me understand issue is.

your use of search dates correct. there bugs in area, have been fixed in version 1.8.4.

a couple of points of clarification:

  1. dates stored @ millisecond resolution, they're indexed @ resolution of 1 day. so, purposes of searching , sorting have date, not time of day. when examine retrieved document, date fields have been restored millisecond precision.

  2. dates appear in query (in yyyy-mm-dd form) considered in utc time zone. implication of bit subtle:

    let's you're sitting in australia @ 2:00am on 2013/9/10, , decide insert document then-current time. on in greenwich it's not yet midnight; date still september 9. if search document date, find [date=2013/09/09] not [date=2013/09/10].

    similarly, if you're sitting in california @ 9:00pm 1 night, it's past midnight in utc ...

  3. there seems bug in dev server admin console. on full text search page, if display document content includes date, date rendered in local time zone instead of utc. , not include time component.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -