Using the _mapping api

Hi,
I am using the _mapping api to learn more about the fields I have in my
mapping. One result seems weird to me when looking at the object returned.

http://localhost:9200/gridshore/_mapping?pretty

{
gridshore: {
blog: {
properties: {
...
}
}
}
}

http://localhost:9200/gridshore/blog/_mapping?pretty

{
blog: {
properties: {
...
}
}
}

So the index is omitted from the result. Is there is reason to do this, or
is it a bug?

thanks,
Jettro

--
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.

Hello Jettro,

I find this behavior pretty normal. Although different people have
different opinions :slight_smile: Here are my thoughts on the subject:

The second command is for getting a specific mapping. The point isn't for
you to see the full path, but only what you asked for, that's why it only
shows you the name of the mapping you requested.

The first command will give you all the mappings (corresponding to all the
types) of your index. It shows you the index name there because you need to
know which mapping you're looking at. It might look obvious, that
"gridshore" is the index name, because you requested it, but you can get
mappings for all indices, for example:

curl localhost:9200/_mapping?pretty

Or multiple indices and/or multiple types within them, like:

curl localhost:9200/test,test2/testmap1,testmap2/_mapping?pretty

In which case you need the index name in the returning JSON. So I think the
point is to have the index name only when you request multiple mappings -
that is, when you're likely to need it.

Best regards,
Radu

On Mon, Jul 8, 2013 at 5:45 PM, Jettro Coenradie <jettro.coenradie@gmail.com

wrote:

Hi,
I am using the _mapping api to learn more about the fields I have in my
mapping. One result seems weird to me when looking at the object returned.

http://localhost:9200/gridshore/_mapping?pretty

{
gridshore: {
blog: {
properties: {
...
}
}
}
}

http://localhost:9200/gridshore/blog/_mapping?pretty

{
blog: {
properties: {
...
}
}
}

So the index is omitted from the result. Is there is reason to do this, or
is it a bug?

thanks,
Jettro

--
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.

--
http://sematext.com/ -- ElasticSearch -- Solr -- Lucene

--
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.

Hi Radu, thank you for your answer. I know there is more to it. But what if
you do this:

http://localhost:9200/_all/blog-item/_mapping?pretty

Than you do not get back the index, so you get back the type without the
index it belongs to. I am not sure, is it possible to create a type without
an index and reuse the same type among indexes?

In any case, it just makes doing my generic stuff a bit harder, in the end
I'll go around it.

regards Jettro

Op maandag 8 juli 2013 19:02:22 UTC+2 schreef Radu Gheorghe het volgende:

Hello Jettro,

I find this behavior pretty normal. Although different people have
different opinions :slight_smile: Here are my thoughts on the subject:

The second command is for getting a specific mapping. The point isn't for
you to see the full path, but only what you asked for, that's why it only
shows you the name of the mapping you requested.

The first command will give you all the mappings (corresponding to all the
types) of your index. It shows you the index name there because you need to
know which mapping you're looking at. It might look obvious, that
"gridshore" is the index name, because you requested it, but you can get
mappings for all indices, for example:

curl localhost:9200/_mapping?pretty

Or multiple indices and/or multiple types within them, like:

curl localhost:9200/test,test2/testmap1,testmap2/_mapping?pretty

In which case you need the index name in the returning JSON. So I think
the point is to have the index name only when you request multiple mappings

  • that is, when you're likely to need it.

Best regards,
Radu

On Mon, Jul 8, 2013 at 5:45 PM, Jettro Coenradie <jettro.c...@gmail.com<javascript:>

wrote:

Hi,
I am using the _mapping api to learn more about the fields I have in my
mapping. One result seems weird to me when looking at the object returned.

http://localhost:9200/gridshore/_mapping?pretty

{
gridshore: {
blog: {
properties: {
...
}
}
}
}

http://localhost:9200/gridshore/blog/_mapping?pretty

{
blog: {
properties: {
...
}
}
}

So the index is omitted from the result. Is there is reason to do this,
or is it a bug?

thanks,
Jettro

--
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.

--
http://sematext.com/ -- ElasticSearch -- Solr -- Lucene

--
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.

Hi Jettro,

On Tue, Jul 9, 2013 at 9:15 AM, Jettro Coenradie <jettro.coenradie@gmail.com

wrote:

Hi Radu, thank you for your answer. I know there is more to it. But what
if you do this:

http://localhost:9200/_all/blog-item/_mapping?pretty

It seems to me that it will just return the first "blog-item" mapping it
finds. For example, if you have two indices with this mapping, the command
above will only return one of them. And you probably wouldn't know which
index it comes from.

Than you do not get back the index, so you get back the type without the
index it belongs to. I am not sure, is it possible to create a type without
an index and reuse the same type among indexes?

No, you can't create a type without an index. But you can use templates
where you can automatically create the same mappings to all new indices
that match the template pattern:
http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/

In any case, it just makes doing my generic stuff a bit harder, in the end
I'll go around it.

Can you share what is the generic stuff you're trying to do here?

Best regards,
Radu

http://sematext.com/ -- ElasticSearch -- Solr -- Lucene

--
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 am working on a plugin:


http://www.gridshore.nl/esgui/#/home

At the moment I am thinking about a better way to present a dropdown with
all possible fields. I want to limit the fields based on prior selected
index(es) or type(s). It would be nice if the result of the following type
of queries would have the same structure:

http://localhost:9200/_mapping
http://localhost:9200/index_a/_mapping
http://localhost:9200/index_a,index_b/_mapping
http://localhost:9200/index_a/type_a/_mapping
http://localhost:9200/index_a/type_a,type_b/_mapping
http://localhost:9200/*/type_a/_mapping
http://localhost:9200/_all/type_a/_mapping

On Tue, Jul 9, 2013 at 8:56 AM, Radu Gheorghe radu.gheorghe@sematext.comwrote:

Hi Jettro,

On Tue, Jul 9, 2013 at 9:15 AM, Jettro Coenradie <
jettro.coenradie@gmail.com> wrote:

Hi Radu, thank you for your answer. I know there is more to it. But what
if you do this:

http://localhost:9200/_all/blog-item/_mapping?pretty

It seems to me that it will just return the first "blog-item" mapping it
finds. For example, if you have two indices with this mapping, the command
above will only return one of them. And you probably wouldn't know which
index it comes from.

Than you do not get back the index, so you get back the type without the
index it belongs to. I am not sure, is it possible to create a type without
an index and reuse the same type among indexes?

No, you can't create a type without an index. But you can use templates
where you can automatically create the same mappings to all new indices
that match the template pattern:
http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/

In any case, it just makes doing my generic stuff a bit harder, in the
end I'll go around it.

Can you share what is the generic stuff you're trying to do here?

Best regards,
Radu

http://sematext.com/ -- ElasticSearch -- Solr -- Lucene

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/EZyxjQeD3rk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Jettro Coenradie

--
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.

Ah, I see now. I see that this one does show you indices:

curl localhost:9200/*/a/_mapping?pretty

Anyway, I understand the problem now. Maybe an option is to just open an
issue and maybe they'll make it more consistent.

By the way, the UI shapes up really nice :slight_smile:

On Tue, Jul 9, 2013 at 11:31 AM, Jettro Coenradie <
jettro.coenradie@gridshore.nl> wrote:

I am working on a plugin:
https://github.com/jettro/elasticsearch-gui
http://www.gridshore.nl/esgui/#/home

At the moment I am thinking about a better way to present a dropdown with
all possible fields. I want to limit the fields based on prior selected
index(es) or type(s). It would be nice if the result of the following type
of queries would have the same structure:

http://localhost:9200/_mapping
http://localhost:9200/index_a/_mapping
http://localhost:9200/index_a,index_b/_mapping
http://localhost:9200/index_a/type_a/_mapping
http://localhost:9200/index_a/type_a,type_b/_mapping
http://localhost:9200/*/type_a/_mapping
http://localhost:9200/_all/type_a/_mapping

On Tue, Jul 9, 2013 at 8:56 AM, Radu Gheorghe radu.gheorghe@sematext.comwrote:

Hi Jettro,

On Tue, Jul 9, 2013 at 9:15 AM, Jettro Coenradie <
jettro.coenradie@gmail.com> wrote:

Hi Radu, thank you for your answer. I know there is more to it. But what
if you do this:

http://localhost:9200/_all/blog-item/_mapping?pretty

It seems to me that it will just return the first "blog-item" mapping it
finds. For example, if you have two indices with this mapping, the command
above will only return one of them. And you probably wouldn't know which
index it comes from.

Than you do not get back the index, so you get back the type without the
index it belongs to. I am not sure, is it possible to create a type without
an index and reuse the same type among indexes?

No, you can't create a type without an index. But you can use templates
where you can automatically create the same mappings to all new indices
that match the template pattern:
http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/

In any case, it just makes doing my generic stuff a bit harder, in the
end I'll go around it.

Can you share what is the generic stuff you're trying to do here?

Best regards,
Radu

http://sematext.com/ -- ElasticSearch -- Solr -- Lucene

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/EZyxjQeD3rk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
Jettro Coenradie
http://www.gridshore.nl

--
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.

--
http://sematext.com/ -- ElasticSearch -- Solr -- Lucene

--
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.

Will do that, thanks for thinking with me.

On Tue, Jul 9, 2013 at 10:38 AM, Radu Gheorghe
radu.gheorghe@sematext.comwrote:

Ah, I see now. I see that this one does show you indices:

curl localhost:9200/*/a/_mapping?pretty

Anyway, I understand the problem now. Maybe an option is to just open an
issue and maybe they'll make it more consistent.

By the way, the UI shapes up really nice :slight_smile:

On Tue, Jul 9, 2013 at 11:31 AM, Jettro Coenradie <
jettro.coenradie@gridshore.nl> wrote:

I am working on a plugin:
https://github.com/jettro/elasticsearch-gui
http://www.gridshore.nl/esgui/#/home

At the moment I am thinking about a better way to present a dropdown with
all possible fields. I want to limit the fields based on prior selected
index(es) or type(s). It would be nice if the result of the following type
of queries would have the same structure:

http://localhost:9200/_mapping
http://localhost:9200/index_a/_mapping
http://localhost:9200/index_a,index_b/_mapping
http://localhost:9200/index_a/type_a/_mapping
http://localhost:9200/index_a/type_a,type_b/_mapping
http://localhost:9200/*/type_a/_mapping
http://localhost:9200/_all/type_a/_mapping

On Tue, Jul 9, 2013 at 8:56 AM, Radu Gheorghe <radu.gheorghe@sematext.com

wrote:

Hi Jettro,

On Tue, Jul 9, 2013 at 9:15 AM, Jettro Coenradie <
jettro.coenradie@gmail.com> wrote:

Hi Radu, thank you for your answer. I know there is more to it. But
what if you do this:

http://localhost:9200/_all/blog-item/_mapping?pretty

It seems to me that it will just return the first "blog-item" mapping it
finds. For example, if you have two indices with this mapping, the command
above will only return one of them. And you probably wouldn't know which
index it comes from.

Than you do not get back the index, so you get back the type without
the index it belongs to. I am not sure, is it possible to create a type
without an index and reuse the same type among indexes?

No, you can't create a type without an index. But you can use templates
where you can automatically create the same mappings to all new indices
that match the template pattern:
http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/

In any case, it just makes doing my generic stuff a bit harder, in the
end I'll go around it.

Can you share what is the generic stuff you're trying to do here?

Best regards,
Radu

http://sematext.com/ -- ElasticSearch -- Solr -- Lucene

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/EZyxjQeD3rk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
Jettro Coenradie
http://www.gridshore.nl

--
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.

--
http://sematext.com/ -- ElasticSearch -- Solr -- Lucene

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/EZyxjQeD3rk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Jettro Coenradie

--
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.