java - Google Search API: Loading all datastore data into document builder for full text search on all records -


i have been following tutorial regarding google search api @ https://developers.google.com/appengine/docs/java/search/overview. information have found clear on how build document , load index. not sure of how load datastore data document.

what trying achieve simple %like% query on few fields. example, working on music library. if user types in "glory", use search api return entities "glory" somewhere in title. have implemented "starts with" work around adding search text "\ufffd", however, find insufficient. users novice, , helpful if didn't have pick field in traditional search. full text search seems solution.

here questions:

  1. should each record in datastore document? or records 1 document? have pretty fixed datastore size of 1000 records. provide example of correct method?

  2. i return entire datastore entity (it's 8 fields) iterable of type of entity. specify each field need return? example says:

    for (scoreddocument scoreddocument : results) { // process scoreddocument }

does have example of comes out of stored document? put in or must identify each field again? or example of processes scoreddocument returning datastore entities?

if fill in these blanks me, appreciate it.

thank looking @ me.

what trying achieve simple %like% query on few fields

in order achieve need "tokenize" records name, gae provides full text search in order partial matches need add partial matches every record so:

if record's name "glory" should add tokens "g","gl","glo","glor","y","ry","ory","lory"

here's basic implementation use provide partial search results (only "starts with" not implementing "end with")

public void addfield(string name, string value, boolean tokenize) {     addfield(field.newbuilder().setname(name).settext(value));     if (tokenize) {         (int = starttokenindex ; < value.length() ;i++) {             addfield(field.newbuilder().setname("token" + (lasttokenindex++))                     .settext(value.substring(0, i)));         }      } } 

should each record in datastore document?

yes. match document id entity's datastore id quick matching. (or can add separate field)

i return entire datastore entity (it's 8 fields) iterable of type of entity. specify each field need return?

you need store entity's id in document, way when search returns set of documents retrieve entities ids.

does have example of comes out of stored document? put in or must identify each field again? or example of processes scoreddocument returning datastore entities?

documents return fields stored in them, plus lot of data scoring, id, etc. "processing" in case consist of getting entity id form document.

if records wont grow above 1000 virtually store within search index. bear in mind index not designed , face serious limitations when scaling, datastore doesn't.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -