Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Search - Document - Missing properties should not throw exceptions #184

Closed
codeconsole opened this Issue Dec 11, 2012 · 5 comments

Comments

Projects
None yet
3 participants
Contributor

codeconsole commented Dec 11, 2012

 groovy.lang.GroovyRuntimeException: No such field 'title' for document 'ScoredDocument(documentId=48307921, fields=[Field(name=created, value=2012-06-29T00:00:00.000Z, type=DATE, locale=en), Field(name=tags, value=nude, type=ATOM, locale=en), Field(name=licenseType, value=STOCK, type=ATOM, locale=en), Field(name=modelCount, value=0, type=NUMBER), Field(name=rating, value=738.879, type=NUMBER), Field(name=options, value=embeddable, type=ATOM)], locale=en, rank=61221554, scores=[734.4656572151837], expressions=[])'

Contributor

glaforge commented Dec 11, 2012

It should fail silently? just returning null?
How do you differentiate a field that would contain null vs a non-existant field?

Contributor

codeconsole commented Dec 11, 2012

should you be differentiating? the problem is you can not have null values in documents for certain types. So the question becomes how do you iterate through results and display them in a gtpl page? Do you need to test for each property?

Is there a reason why it should fail? If so, how would you accomplish iteration?

Doesn't Entity to POGO coercion currently fail silently?

Contributor

glaforge commented Dec 11, 2012

I'm okay with the change to just return null, I'm not against it.
I was just curious about how users differentiate the two cases.
The API probably offers a solution like hasProperty or some similar method?

Contributor

codeconsole commented Dec 11, 2012

https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api/search/Document

All there is is getField(String name) and getFields(String name) which both return null if the field does not exist.
They do not thrown an exception.

Contributor

glaforge commented Dec 11, 2012

Okie dokie, so let's just go with returning null (ie. failing silently)

@ghost ghost assigned musketyr Dec 12, 2012

@musketyr musketyr closed this in 86c53b2 Dec 13, 2012

musketyr added a commit that referenced this issue Dec 17, 2012

fixed #184
Conflicts:

	core/src/main/groovyx/gaelyk/extensions/SearchExtensions.groovy
	core/src/test/groovyx/gaelyk/search/SearchShortcutsTest.groovy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment