Skip to content

Mappings defined at index creation time in YAML are ignored #1755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yannk opened this issue Mar 3, 2012 · 4 comments
Closed

Mappings defined at index creation time in YAML are ignored #1755

yannk opened this issue Mar 3, 2012 · 4 comments

Comments

@yannk
Copy link

yannk commented Mar 3, 2012

According to documentation I would have assumed that creation of mappings work in YAML too (since the first example on that page uses it):
http://www.elasticsearch.org/guide/reference/api/admin-indices-create-index.html

In JSON, it works as expected:

{
    "settings": {
        "number_of_shards": 1,
        "number_of_replicas": 0
    },
    "content": {  
        "properties": {  
             "exact": {
                "index": "not_analyzed",
                "type": "string"
            }
        }
    }
}

But, the following doesn't work:


curl -XPUT $SERVER/$INDEX/ -d '
settings:
        number_of_shards: 1
        number_of_replicas: 0
mappings:
    content:
        properties:
            exact:
                index: not_analyzed
                type: string
'

Below is my indexing and searching setup:


curl -XPUT $SERVER/$INDEX/content/1 -d '  
{"exact": "The Field", "title": "one" }  
'  
curl -XPUT $SERVER/$INDEX/content/2 -d '  
{"exact": "Astro Nomical", "title": "The second title" }  
'                                                                                         

curl -XPOST $SERVER/$INDEX/_refresh                                                       

curl -XPOST $SERVER/$INDEX/content/_search -d '  
{  
  "query": {  
    "filtered": {  
      "filter": {  
        "term": {  
          "exact": "The Field"  
        }  
      },  
      "query": {  
        "match_all": {}  
      } 
    }  
  }  
} 
'

tested with 0.18 and 0.19.
Sorry for formatting. Github Markdown seems broken.

@kimchy
Copy link
Member

kimchy commented Mar 3, 2012

Not for the create index API, in this case, ti is expected to be in json...

@kimchy
Copy link
Member

kimchy commented Mar 3, 2012

Sorry, I meant when you provide both settings and mappings, it is expected to be provided in json, not yml. Only when you create just with settings, it supports yml. I will fix the docs.

@yannk
Copy link
Author

yannk commented Mar 3, 2012

Thanks! I'm sure documenting this will be useful to others.

@swackhamer
Copy link

Is this still the case? The documentation is still unclear: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html

tvernum added a commit that referenced this issue Feb 25, 2025
"stashing" the thread context is typically used to execute something
with a differenet set of privileges (access to system indices, or a
different user). In these cases we don't want to lose the project-id
from the context (just like we don't want to lose APM tracing
information).

This change preserves the project-id during stash.
tvernum added a commit that referenced this issue Feb 25, 2025
This unmutes a number of security-related YAML tests that correctly
function now that we have merged the following PRs

- #1752
- #1755
- #1764 
- #1771
- #1772
- #1775
- #1782
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants