Doc._version as script_value


(fatA) #1

Hello,
I am tring to use versioning feature as increment counter. I got
documents like {"event":"event1"} and i put them when and event
happens, so every time i put version is incremented.

I can search that index and i use version as event counter.

One response is:
{
"_index" : "events",
"_type" : "counter",
"_id" : "97",
"_version" : 3814,
"_score" : 1.0, "_source" : {"event": "event1"}
}

Here i use 3814 as counter.

But i would like to do a facet too. Like

{
"version":
true,
"query" :
{
"match_all":
{ }
},
"facets":
{
"ms":
{
"terms_stats":
{
"key_field":
"event",
"value_script":
"doc._version"
}
}
}
}

I get
Query Failed [Failed to execute main query]]; nested:
PropertyAccessException[[Error: could not access: _version; in class:
org.elasticsearch.search.lookup.DocLookup]\n[Near : {...
doc._version ....}]\n ^\n[Line: 1, Column: 1]]

How can i access version of a document in facet?

Thanks


(Shay Banon) #2

Version is not exposed as a "doc" value in scripts. Open an issue, can be added (though requires some thought, and if the realtime value should be exposed or the "last refresh" value).
On Monday, May 9, 2011 at 12:04 PM, OT wrote:

Hello,
I am tring to use versioning feature as increment counter. I got
documents like {"event":"event1"} and i put them when and event
happens, so every time i put version is incremented.

I can search that index and i use version as event counter.

One response is:
{
"_index" : "events",
"_type" : "counter",
"_id" : "97",
"_version" : 3814,
"_score" : 1.0, "_source" : {"event": "event1"}
}

Here i use 3814 as counter.

But i would like to do a facet too. Like

{
"version":
true,
"query" :
{
"match_all":
{ }
},
"facets":
{
"ms":
{
"terms_stats":
{
"key_field":
"event",
"value_script":
"doc._version"
}
}
}
}

I get
Query Failed [Failed to execute main query]]; nested:
PropertyAccessException[[Error: could not access: _version; in class:
org.elasticsearch.search.lookup.DocLookup]\n[Near : {...
doc._version ....}]\n ^\n[Line: 1, Column: 1]]

How can i access version of a document in facet?

Thanks


(system) #3