I'm trying to write a little Unit Test to check that we setting up our
objects correctly. To do this I'm setting up a FacetBuilder and
convert it to Json that from where I can assert its correctness.
However, when I try to convert the FacetBuilder to Json I get an
Exception:
org.elasticsearch.common.jackson.JsonGenerationException: Can not
write a field name, expecting a value
at
org.elasticsearch.common.jackson.impl.JsonGeneratorBase._reportError(JsonGeneratorBase.java:
480)
at
org.elasticsearch.common.jackson.impl.Utf8Generator.writeFieldName(Utf8Generator.java:
270)
at
org.elasticsearch.common.xcontent.json.JsonXContentGenerator.writeFieldName(JsonXContentGenerator.java:
70)
at
org.elasticsearch.common.xcontent.XContentBuilder.field(XContentBuilder.java:
253)
at
org.elasticsearch.common.xcontent.XContentBuilder.startObject(XContentBuilder.java:
139)
at
org.elasticsearch.search.facet.terms.TermsFacetBuilder.toXContent(TermsFacetBuilder.java:
211)
I tried both versions 0.17.4 and 0.17.7 with pretty consistent results
(StackTrace is for 0.17.7)
I fired up a debugger and stepped through the code and there is
nothing that is null or otherwise broken.
I'm trying to write a little Unit Test to check that we setting up our
objects correctly. To do this I'm setting up a FacetBuilder and
convert it to Json that from where I can assert its correctness.
However, when I try to convert the FacetBuilder to Json I get an
Exception:
One more question if you don't mind: What confused me was that a
Filter Builder happily creates json without the startObject() but a
Facet Builder doesn't. Is there something that I can use to predict
when it is required?
I'm trying to write a little Unit Test to check that we setting up our
objects correctly. To do this I'm setting up a FacetBuilder and
convert it to Json that from where I can assert its correctness.
However, when I try to convert the FacetBuilder to Json I get an
Exception:
Its because of the expected stage at which those different elements (query,
filter, facet) are used within the search request. Sometimes, they need to
be in the form of { ... } (like filters), and sometimes, they need to be
outputted like "name" : { ... } (in case of facets), to be pluggable into
the the full search request.
One more question if you don't mind: What confused me was that a
Filter Builder happily creates json without the startObject() but a
Facet Builder doesn't. Is there something that I can use to predict
when it is required?
I'm trying to write a little Unit Test to check that we setting up our
objects correctly. To do this I'm setting up a FacetBuilder and
convert it to Json that from where I can assert its correctness.
However, when I try to convert the FacetBuilder to Json I get an
Exception:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.