Is it possible to use String as _id?


(Yz) #1

Through my experiment, it seems not possible to use string as primary key
in Elasticsearch.
If type String is used , then the _id will be something like this:
"_id":"[B@fe583b"
which uses the object address in jvm instead of the real value.
So, is there any way to generate a composite _id from two integer value?

--
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/f073e04b-f2a1-4e5a-a7e0-ff93727f6e9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Brian Yoder) #2

The _id (metadata _id, that is) is a string value.

The value of the _id string is whatever you set it to (or else a long
string automatically generated by Elasticsearch when the document is
created). You have complete freedom to set it to any string value you wish.

The _id metadata is the closest thing ES has to a unique constraint, and I
use it quite effectively in this way.

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/a311ee25-b4e9-4155-9543-55eb7a199bcd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Adrien Grand) #3

Can you share the code that you used to trigger this issue?

On Mon, Apr 28, 2014 at 4:39 PM, Yz yingzhong.xu@gmail.com wrote:

Through my experiment, it seems not possible to use string as primary key
in Elasticsearch.
If type String is used , then the _id will be something like this:
"_id":"[B@fe583b"
which uses the object address in jvm instead of the real value.
So, is there any way to generate a composite _id from two integer value?

--
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/f073e04b-f2a1-4e5a-a7e0-ff93727f6e9f%40googlegroups.comhttps://groups.google.com/d/msgid/elasticsearch/f073e04b-f2a1-4e5a-a7e0-ff93727f6e9f%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
Adrien Grand

--
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/CAL6Z4j6%3D%2BZ0sTOUZpaaW6stOESDn67WSAskNXd88wiFgfp7RTQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(Yz) #4

So, it seems to be mysql_jdbc_river's problem?
Here is my sql query:
"SELECT concat(fid,cmid) as _id .... FROM forum JOIN comment ..."
I set the concatenation of two integer fields to be the primary key and
causes the problem I described above..
Now I am dividing two tables into separate Types within an Index and using
their own integer id as the primary key.

On Monday, April 28, 2014 11:00:42 PM UTC+8, Adrien Grand wrote:

Can you share the code that you used to trigger this issue?

On Mon, Apr 28, 2014 at 4:39 PM, Yz <yingzh...@gmail.com <javascript:>>wrote:

Through my experiment, it seems not possible to use string as primary key
in Elasticsearch.
If type String is used , then the _id will be something like this:
"_id":"[B@fe583b"
which uses the object address in jvm instead of the real value.
So, is there any way to generate a composite _id from two integer value?

--
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:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/f073e04b-f2a1-4e5a-a7e0-ff93727f6e9f%40googlegroups.comhttps://groups.google.com/d/msgid/elasticsearch/f073e04b-f2a1-4e5a-a7e0-ff93727f6e9f%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
Adrien Grand

--
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/9eaa22ea-8102-40a7-9f84-97f571ce9ef7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #5