It throws error as
QueryPhaseExecutionException[[twitter][2]: query[custom score
(ConstantScore(:),function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser
$ScriptScoreFunction@13ff9d4)],from[0],size[10]: Query Failed [Failed
to execute main query]]; nested: CompileException[[Error: No field
found for
[org.elasticsearch.index.field.data.strings.StringDocFieldData@2a09a0]]
\n[Near : {... _score * doc[user] ....}]\n ^\n[Line: 1,
Column: 1]]; nested: ElasticSearchIllegalArgumentException[No field
found for
[org.elasticsearch.index.field.data.strings.StringDocFieldData@2a09a0]];
Now if I want to use _source.user then it gives correct output. Can
somebody tell me what is the difference in doc['field_name'] and
_source.field_name and when to use it?
Can I use non-numeric values in source.field_name and use functions on
them like .toString.length()
Now my custom query is
curl -XGET localhost:9200/twitter/script/_search?pretty=true -d '
{
"query":
{
"custom_score" : {
"query" : {
"match_all" : {}
},
"script" : "_score * doc['user']"
}
}
}'
It throws error as
QueryPhaseExecutionException[[twitter][2]: query[custom score
(ConstantScore(:),function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser
$ScriptScoreFunction@13ff9d4)],from[0],size[10]: Query Failed [Failed
to execute main query]]; nested: CompileException[[Error: No field
found for
[org.elasticsearch.index.field.data.strings.StringDocFieldData@2a09a0]]
\n[Near : {... _score * doc[user] ....}]\n ^\n[Line: 1,
Column: 1]]; nested: ElasticSearchIllegalArgumentException[No field
found for
[org.elasticsearch.index.field.data.strings.StringDocFieldData@2a09a0]];
Now if I want to use _source.user then it gives correct output. Can
somebody tell me what is the difference in doc['field_name'] and
_source.field_name and when to use it?
Can I use non-numeric values in source.field_name and use functions on
them like .toString.length()
Now if I want to use _source.user then it gives correct output. Can
somebody tell me what is the difference in doc['field_name'] and
_source.field_name and when to use it?
Can I use non-numeric values in source.field_name and use functions on
them like .toString.length()
On Wed, 2011-07-06 at 02:58 -0700, nachiket bhagwat wrote:
Hi. I have looked at the module already but could not understand it.
My question is if my script is like
{"script": "_score + _source.email.length"} then it throws an error in
documents that do not contain that field and do not retreive the docs
even if the query is working.
If you look at the docs on
you will see that it uses "doc['fieldname'].value" and variants.
So for you example above, try:
"_score + doc['email'].stringValue.length()/10"
Here I just want to define priority of documents and hence I am using
'+' in script to change scoring function. But it is changing my
definition of relevant and not relevant.
How can I do above thing? Is it possible in scripting to retrive docs
even if some fields have null values??
I'm not sure if stringValue will take care of the null values or not.
If it doesn't then check if that field has a value before applying the
rest of the calculation.
My final question is what does doc['field_name'] means? If the doc
means current doc can I use it in any script? It is not working as I
stated in earlier message. Also can I access like
doc['obj1.field_name']?
Hi.
Thanks for the help.
But I am still getting same error on the last point.
If I use _souce.field_name then it gives output correctly but instead
if I use doc['field_name'] (Even without nesting) then it throws an
error.
nested: ElasticSearchIllegalArgumentException
[No field found for
I am not getting difference between those. In documentation there is a
point that
"In all scripts that can be used in facets, allow to access the
current doc score using doc.score"
Does this mean there are only some of scripts where I can use
doc['field_name'] and its variants?
On Wed, 2011-07-06 at 02:58 -0700, nachiket bhagwat wrote:
Hi. I have looked at the module already but could not understand it.
My question is if myscriptis like
{"script": "_score + _source.email.length"} then it throws anerrorin
documents that do not contain that field and do not retreive the docs
even if the query is working.
If you look at the docs onhttp://www.elasticsearch.org/guide/reference/modules/scripting
you will see that it uses "doc['fieldname'].value" and variants.
So for you example above, try:
"_score + doc['email'].stringValue.length()/10"
Here I just want to define priority of documents and hence I am using
'+' inscriptto change scoring function. But it is changing my
definition of relevant and not relevant.
How can I do above thing? Is it possible in scripting to retrive docs
even if some fields have null values??
I'm not sure if stringValue will take care of the null values or not.
If it doesn't then check if that field has a value before applying the
rest of the calculation.
My final question is what does doc['field_name'] means? If the doc
means current doc can I use it in anyscript? It is not working as I
stated in earlier message. Also can I access like
doc['obj1.field_name']?
Hi.
My script works if I am using _source.field_name but doesn't work if I
use doc['field_name'] (or its variants as stated in documentation).
Can somebody tell me if there is any difference in these two?
If yes how can I use functions like distance() etc using
_source.field_name ?
On Wed, 2011-07-06 at 02:58 -0700, nachiket bhagwat wrote:
Hi. I have looked at the module already but could not understand it.
My question is if my script is like
{"script": "_score + _source.email.length"} then it throws an error in
documents that do not contain that field and do not retreive the docs
even if the query is working.
If you look at the docs onhttp://www.elasticsearch.org/guide/reference/modules/scripting
you will see that it uses "doc['fieldname'].value" and variants.
So for you example above, try:
"_score + doc['email'].stringValue.length()/10"
Here I just want to define priority of documents and hence I am using
'+' in script to change scoring function. But it is changing my
definition of relevant and not relevant.
How can I do above thing? Is it possible in scripting to retrive docs
even if some fields have null values??
I'm not sure if stringValue will take care of the null values or not.
If it doesn't then check if that field has a value before applying the
rest of the calculation.
My final question is what does doc['field_name'] means? If the doc
means current doc can I use it in any script? It is not working as I
stated in earlier message. Also can I access like
doc['obj1.field_name']?
What I can't figure out is how scripts work.
I mean _source.field_name works for a field but instead if I use
doc['field_name'] it throws an error like No field found for
'field_name'.
Is there any difference between those too on logical level?
If yes how can I use functions like getDistance etc?
On Wed, 2011-07-06 at 02:58 -0700, nachiket bhagwat wrote:
Hi. I have looked at the module already but could not understand it.
My question is if myscriptis like
{"script": "_score + _source.email.length"} then it throws anerrorin
documents that do not contain that field and do not retreive the docs
even if the query is working.
If you look at the docs onhttp://www.elasticsearch.org/guide/reference/modules/scripting
you will see that it uses "doc['fieldname'].value" and variants.
So for you example above, try:
"_score + doc['email'].stringValue.length()/10"
Here I just want to define priority of documents and hence I am using
'+' inscriptto change scoring function. But it is changing my
definition of relevant and not relevant.
How can I do above thing? Is it possible in scripting to retrive docs
even if some fields have null values??
I'm not sure if stringValue will take care of the null values or not.
If it doesn't then check if that field has a value before applying the
rest of the calculation.
My final question is what does doc['field_name'] means? If the doc
means current doc can I use it in anyscript? It is not working as I
stated in earlier message. Also can I access like
doc['obj1.field_name']?
Hi.
I was not able to post in my earlier post Errot in script. So I am
starting new discussion.
I want to understand basic difference between doc['field_name'] ,
_fields['field_name'] and _source.field_name.
My query works for _source.field_name but same query when
doc['field_name'] is used throws an error named
"ElasticSearchIllegalArgumentException : No field found for ......"
So there must be some difference between those three.
Can somebody help me with this issue?
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.