Java DSL and Query DSL different results

Hello, when i run this query...

{"filter":{"exists":{"field":"NUM_OF_WKS"}}, * "fields" : ["NUM_OF_WKS"]*,
"facets" :
{"Number_of_Weeks_Facet":{"terms":{"field":"NUM_OF_WKS","size":"1"} }}}

I corerctly get only the NUM_OF_WKS fleld back

but when i set the same query into a java search, i get null for that
fiels

final SearchResponse response = client.search(new
SearchRequest("scnprobldir3a").types("dimItem").source("{"filter":{"exists":{"field":"NUM_OF_WKS"}},
*"fields" : ["NUM_OF_WKS"]*, "facets" :
{"Number_of_Weeks_Facet":{"terms":{"field":"NUM_OF_WKS","size":"100"}
}}}")).actionGet();

Can anyone help with this

thank you !

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Instead ".source(...)", maybe ".setExtraSource(...)" works...

When I use filters, or size offset, I use extraSource() in
SearchRequestBuilder()

Jörg

Am 04.03.13 21:21, schrieb eric sanford:

Hello, when i run this query...

{"filter":{"exists":{"field":"NUM_OF_WKS"}}, * "fields" :
["NUM_OF_WKS"]*, "facets" :
{"Number_of_Weeks_Facet":{"terms":{"field":"NUM_OF_WKS","size":"1"} }}}

I corerctly get only the NUM_OF_WKS fleld back

but when i set the same query into a java search, i get null for
that fiels

final SearchResponse response = client.search(new
SearchRequest("scnprobldir3a").types("dimItem").source("{"filter":{"exists":{"field":"NUM_OF_WKS"}},
*"fields" : ["NUM_OF_WKS"]*, "facets" :
{"Number_of_Weeks_Facet":{"terms":{"field":"NUM_OF_WKS","size":"100"}
}}}")).actionGet();

Can anyone help with this

thank you !

You received this message because you are subscribed to the Google
Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Not sure of what happen here but, in Java, I recommend to use helper methods.
I will probably write your query like this:

    SearchResponse response = client.prepareSearch("scnprobldir3a")
            .setTypes("dimItem")
            .addField("NUM_OF_WKS")
            .setFilter(FilterBuilders.existsFilter("NUM_OF_WKS"))
            .addFacet(FacetBuilders.termsFacet("Number_of_Weeks_Facet").field("NUM_OF_WKS").size(100))
            .execute().actionGet();

See java API documentation: http://www.elasticsearch.org/guide/reference/java-api/

Does it help?

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 4 mars 2013 à 21:21, eric sanford pcstechnologiesinc@gmail.com a écrit :

Hello, when i run this query...

{"filter":{"exists":{"field":"NUM_OF_WKS"}}, "fields" : ["NUM_OF_WKS"], "facets" : {"Number_of_Weeks_Facet":{"terms":{"field":"NUM_OF_WKS","size":"1"} }}}

I corerctly get only the NUM_OF_WKS fleld back

but when i set the same query into a java search, i get null for that fiels

final SearchResponse response = client.search(new SearchRequest("scnprobldir3a").types("dimItem").source("{"filter":{"exists":{"field":"NUM_OF_WKS"}}, "fields" : ["NUM_OF_WKS"], "facets" : {"Number_of_Weeks_Facet":{"terms":{"field":"NUM_OF_WKS","size":"100"} }}}")).actionGet();

Can anyone help with this

thank you !

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

I just add a note about your filter.
You should be aware that it's not applied to your facet. So your facet is computed on all documents.

The fact is that when the field NUM_OF_WKS does not exist in the document, no computation is done for that document… :wink:

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 4 mars 2013 à 21:35, David Pilato david@pilato.fr a écrit :

Not sure of what happen here but, in Java, I recommend to use helper methods.
I will probably write your query like this:

    SearchResponse response = client.prepareSearch("scnprobldir3a")
            .setTypes("dimItem")
            .addField("NUM_OF_WKS")
            .setFilter(FilterBuilders.existsFilter("NUM_OF_WKS"))
            .addFacet(FacetBuilders.termsFacet("Number_of_Weeks_Facet").field("NUM_OF_WKS").size(100))
            .execute().actionGet();

See java API documentation: http://www.elasticsearch.org/guide/reference/java-api/

Does it help?

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 4 mars 2013 à 21:21, eric sanford pcstechnologiesinc@gmail.com a écrit :

Hello, when i run this query...

{"filter":{"exists":{"field":"NUM_OF_WKS"}}, "fields" : ["NUM_OF_WKS"], "facets" : {"Number_of_Weeks_Facet":{"terms":{"field":"NUM_OF_WKS","size":"1"} }}}

I corerctly get only the NUM_OF_WKS fleld back

but when i set the same query into a java search, i get null for that fiels

final SearchResponse response = client.search(new SearchRequest("scnprobldir3a").types("dimItem").source("{"filter":{"exists":{"field":"NUM_OF_WKS"}}, "fields" : ["NUM_OF_WKS"], "facets" : {"Number_of_Weeks_Facet":{"terms":{"field":"NUM_OF_WKS","size":"100"} }}}")).actionGet();

Can anyone help with this

thank you !

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

i still dont understand why it works using query DSL but not with java API

i tried extraSource instead of source and i still get nulls but i get
values when i run the same query through Soap UI or the browser

On Monday, March 4, 2013 2:38:22 PM UTC-6, David Pilato wrote:

I just add a note about your filter.
You should be aware that it's not applied to your facet. So your facet is
computed on all documents.

The fact is that when the field NUM_OF_WKS does not exist in the document,
no computation is done for that document… :wink:

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr
| @scrutmydocs https://twitter.com/scrutmydocs

Le 4 mars 2013 à 21:35, David Pilato <da...@pilato.fr <javascript:>> a
écrit :

Not sure of what happen here but, in Java, I recommend to use helper
methods.
I will probably write your query like this:

    SearchResponse response = client.prepareSearch("scnprobldir3a")
            .setTypes("dimItem")
            .addField("NUM_OF_WKS")
            .setFilter(FilterBuilders.existsFilter("NUM_OF_WKS"))

.addFacet(FacetBuilders.termsFacet("Number_of_Weeks_Facet").field("NUM_OF_WKS").size(100))
.execute().actionGet();

See java API documentation:
http://www.elasticsearch.org/guide/reference/java-api/

Does it help?

--
David Pilato | Technical Advocate | *Elasticsearch.comhttp://elasticsearch.com/
*
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr
| @scrutmydocs https://twitter.com/scrutmydocs

Le 4 mars 2013 à 21:21, eric sanford <pcstechno...@gmail.com <javascript:>>
a écrit :

Hello, when i run this query...

{"filter":{"exists":{"field":"NUM_OF_WKS"}}, * "fields" : ["NUM_OF_WKS"]*,
"facets" :
{"Number_of_Weeks_Facet":{"terms":{"field":"NUM_OF_WKS","size":"1"} }}}

I corerctly get only the NUM_OF_WKS fleld back

but when i set the same query into a java search, i get null for that
fiels

final SearchResponse response = client.search(new
SearchRequest("scnprobldir3a").types("dimItem").source("{"filter":{"exists":{"field":"NUM_OF_WKS"}},
*"fields" : ["NUM_OF_WKS"]*, "facets" :
{"Number_of_Weeks_Facet":{"terms":{"field":"NUM_OF_WKS","size":"100"}
}}}")).actionGet();

Can anyone help with this

thank you !

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

ok i get it now :slight_smile:

thanks for your responses, they helped me track down the issue...

when using a query string that does not specify a field, i get the JSON
data back with hit.sourceAsString()

this is what was null

apparently when it i specify fields the data is available as raw values in
getFields

yes.. im an ES newbie :slight_smile:

thx again for your responses

On Monday, March 4, 2013 2:38:22 PM UTC-6, David Pilato wrote:

I just add a note about your filter.
You should be aware that it's not applied to your facet. So your facet is
computed on all documents.

The fact is that when the field NUM_OF_WKS does not exist in the document,
no computation is done for that document… :wink:

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr
| @scrutmydocs https://twitter.com/scrutmydocs

Le 4 mars 2013 à 21:35, David Pilato <da...@pilato.fr <javascript:>> a
écrit :

Not sure of what happen here but, in Java, I recommend to use helper
methods.
I will probably write your query like this:

    SearchResponse response = client.prepareSearch("scnprobldir3a")
            .setTypes("dimItem")
            .addField("NUM_OF_WKS")
            .setFilter(FilterBuilders.existsFilter("NUM_OF_WKS"))

.addFacet(FacetBuilders.termsFacet("Number_of_Weeks_Facet").field("NUM_OF_WKS").size(100))
.execute().actionGet();

See java API documentation:
http://www.elasticsearch.org/guide/reference/java-api/

Does it help?

--
David Pilato | Technical Advocate | *Elasticsearch.comhttp://elasticsearch.com/
*
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr
| @scrutmydocs https://twitter.com/scrutmydocs

Le 4 mars 2013 à 21:21, eric sanford <pcstechno...@gmail.com <javascript:>>
a écrit :

Hello, when i run this query...

{"filter":{"exists":{"field":"NUM_OF_WKS"}}, * "fields" : ["NUM_OF_WKS"]*,
"facets" :
{"Number_of_Weeks_Facet":{"terms":{"field":"NUM_OF_WKS","size":"1"} }}}

I corerctly get only the NUM_OF_WKS fleld back

but when i set the same query into a java search, i get null for that
fiels

final SearchResponse response = client.search(new
SearchRequest("scnprobldir3a").types("dimItem").source("{"filter":{"exists":{"field":"NUM_OF_WKS"}},
*"fields" : ["NUM_OF_WKS"]*, "facets" :
{"Number_of_Weeks_Facet":{"terms":{"field":"NUM_OF_WKS","size":"100"}
}}}")).actionGet();

Can anyone help with this

thank you !

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

I think you can ask for field _source if you need it.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 5 mars 2013 à 19:28, eric sanford pcstechnologiesinc@gmail.com a écrit :

ok i get it now :slight_smile:

thanks for your responses, they helped me track down the issue...

when using a query string that does not specify a field, i get the JSON data back with hit.sourceAsString()

this is what was null

apparently when it i specify fields the data is available as raw values in getFields

yes.. im an ES newbie :slight_smile:

thx again for your responses

On Monday, March 4, 2013 2:38:22 PM UTC-6, David Pilato wrote:

I just add a note about your filter.
You should be aware that it's not applied to your facet. So your facet is computed on all documents.

The fact is that when the field NUM_OF_WKS does not exist in the document, no computation is done for that document… :wink:

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 4 mars 2013 à 21:35, David Pilato da...@pilato.fr a écrit :

Not sure of what happen here but, in Java, I recommend to use helper methods.
I will probably write your query like this:

    SearchResponse response = client.prepareSearch("scnprobldir3a")
            .setTypes("dimItem")
            .addField("NUM_OF_WKS")
            .setFilter(FilterBuilders.existsFilter("NUM_OF_WKS"))
            .addFacet(FacetBuilders.termsFacet("Number_of_Weeks_Facet").field("NUM_OF_WKS").size(100))
            .execute().actionGet();

See java API documentation: http://www.elasticsearch.org/guide/reference/java-api/

Does it help?

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 4 mars 2013 à 21:21, eric sanford pcstechno...@gmail.com a écrit :

Hello, when i run this query...

{"filter":{"exists":{"field":"NUM_OF_WKS"}}, "fields" : ["NUM_OF_WKS"], "facets" : {"Number_of_Weeks_Facet":{"terms":{"field":"NUM_OF_WKS","size":"1"} }}}

I corerctly get only the NUM_OF_WKS fleld back

but when i set the same query into a java search, i get null for that fiels

final SearchResponse response = client.search(new SearchRequest("scnprobldir3a").types("dimItem").source("{"filter":{"exists":{"field":"NUM_OF_WKS"}}, "fields" : ["NUM_OF_WKS"], "facets" : {"Number_of_Weeks_Facet":{"terms":{"field":"NUM_OF_WKS","size":"100"} }}}")).actionGet();

Can anyone help with this

thank you !

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.