How can I get the metadata from a query result?
In Java can be implemented like this using SQL:
Statement st = connection.createStatement();
ResultSet result = st.executeQuery(sql);
result.getMetaData();
--
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 .
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/b4d14314-13ba-4646-8bd7-541d3a9c5735%40googlegroups.com .
For more options, visit https://groups.google.com/groups/opt_out .
Savio,
You can get it from the SearchHit. For example:
public void loadFrom (SearchHit doc)
{
index = doc.getIndex();
type = doc.getType();
id = doc.getId();
version = doc.getVersion();
try
{
setTTL(extractTTL(doc));
}
catch Exception e)
{
ttl = null;
}
}
public static String extractTTL (SearchHit doc)
{
String ttl = null;
if (doc != null)
{
SearchHitField ttlField = doc.field(TTL_FIELD_NAME);
if (ttlField != null)
{
Value ttlValue = new Value(ttlField.value());
if (ttlValue != null)
return ttlValue.toRawString();
}
}
return ttl;
}
And you would do something similar for a GetResponse object, too (response
from a query-by-id).
Hope this helps!
Brian
--
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 .
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/d7388850-8355-408b-81de-8f91a40004fc%40googlegroups.com .
For more options, visit https://groups.google.com/groups/opt_out .
So, Have I to extract the Java type of each object of response? There is no
way to get metadata directly?
Thanks for the answer!
Em terça-feira, 14 de janeiro de 2014 12h13min44s UTC-2, Savio Teles
escreveu:
How can I get the metadata from a query result?
In Java can be implemented like this using SQL:
Statement st = connection.createStatement();
ResultSet result = st.executeQuery(sql);
result.getMetaData();
--
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 .
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/233e3754-b1da-482f-8c98-b16a30a87b0b%40googlegroups.com .
For more options, visit https://groups.google.com/groups/opt_out .
Ivan
(Ivan Brusic)
January 14, 2014, 5:24pm
4
What metadata are you looking for? Just the column type? Unfortunately
there is no direct way to get the Java type of each response/field. You can
retrieve the mapping from the index [1] and determine which field uses
which type. I am assuming most using the Java API have written their own
ORM layer. Elasticsearch uses Jackson for JSON, so you can always use it to
recreate your objects.
Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.
Cheers,
Ivan
On Tue, Jan 14, 2014 at 8:47 AM, Savio Teles savioteles@gmail.com wrote:
So, Have I to extract the Java type of each object of response? There is
no way to get metadata directly?
Thanks for the answer!
Em terça-feira, 14 de janeiro de 2014 12h13min44s UTC-2, Savio Teles
escreveu:
How can I get the metadata from a query result?
In Java can be implemented like this using SQL:
Statement st = connection.createStatement();
ResultSet result = st.executeQuery(sql);
result.getMetaData();
--
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 .
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/233e3754-b1da-482f-8c98-b16a30a87b0b%40googlegroups.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 .
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQD73awz3jd%2B%3Dh243%3Dnw_45rKY%3Dpi1_%2Bu-Aq-8-RF_ooyg%40mail.gmail.com .
For more options, visit https://groups.google.com/groups/opt_out .
What metadata are you looking for? Just the column type?
Yes, just the column type.
You can retrieve the mapping from the index [1]
Ok! Tks
Em terça-feira, 14 de janeiro de 2014 12h13min44s UTC-2, Savio Teles
escreveu:
How can I get the metadata from a query result?
In Java can be implemented like this using SQL:
Statement st = connection.createStatement();
ResultSet result = st.executeQuery(sql);
result.getMetaData();
--
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 .
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/89e0e3f4-c6bc-45f8-b255-7ac77f3f040d%40googlegroups.com .
For more options, visit https://groups.google.com/groups/opt_out .