google-app-engine
Can someone help me add a new column in Google cloud Search Index using Java
I tried adding a new column to an existing search index but it is throwing an error, the error as stated below:- Field docname is present 0 times; expected 1 java.lang.IllegalArgumentException: Field docname is present 0 times; expected 1 I can see that the new column has been added to the search index but cannot retrieve the index. By my observation i can see that the existing records in the index dont have the new column data and hence it is giving a this error, but the new records will be having this column values. Can anyone help me with this.
Upon having this problem myself today, I searched a bit in the documentation. It was a rather frustrating error as it didn't actually pin point where the problem was in my code. It appears that when you use getOnlyField("something") on a Document (in this case on one of many returned from a search query), if that field does not actually exist yet in that specific document it throws the java.lang.IllegalArgumentException. Because that can often be the case when you update an index with new columns, I'm using something like this to get around it: public static Long getNumberField(ScoredDocument d, String name, Long defaultValue) { try { return d.getOnlyField(name).getNumber().longValue(); } catch (IllegalArgumentException e) { return defaultValue; } } Which is called in the search results code: Long numberValue = SearchUtils.getNumberField(scoredDocument, "featuredOrder", -1L) This allows me to catch that error and return a default value when it doesn't exist. You can find the documentation here: https://cloud.google.com/appengine/docs/java/javadoc/com/google/appengine/api/search/Document.html#getOnlyField-java.lang.String-
Related Links
Trouble while sending Email using Google App Engine to Verizon (vtext.com)
Keeping track of time with 1 second accuracy in Google App Engine
Developing for Google App Engine and using the datastore
GAE Datastore: “total” property vs. adding up line items?
Business intelligence on Google App Engine
Why GAE ChannelAPI Socket.open() fails?
Modifying GAE Django to Expand the API Scope on User Login
GWT: Where (how) to define POJOs to make em available for client and server? (and to use datastore on serverside)
Google App Engine Always On feature
Google App Engine: How to create sub domain/ sub directory
Securing Google App Engine Authsub callback url ('next_url')
Browser-based strategy game in Django/GAE. Model suggestions?
Setting GTalk status using Java - GAE/J
GWT RPC method name at App Engine server log
Is it thread-safe to store data inside a static field when deploying on Google App Engine?
What is the difference between key_id and key_name in App Engine Datastore?