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

During index creation, mapping can't reference an analyzer #2630

Closed
Volune opened this Issue Feb 7, 2013 · 1 comment

Comments

Projects
None yet
2 participants
@Volune
Copy link

Volune commented Feb 7, 2013

The create index API allows to provide mappings:

curl -XPOST localhost:9200/test1 -d '{
    "settings" : {
        "number_of_shards" : 1
    },
    "analysis" : {
        "analyzer": {
            "an_analyzer": { "type" : "keyword" }
        }
    },
    "mappings" : {
        "a_type" : {
            "properties" : {
                "a_field" : { "type" : "string" }
            }
        }
    }
}'

But I can't use an analyzer in the mapping at this time, like in the following example:
curl -XPOST localhost:9200/test2 -d '{
    "settings" : {
        "number_of_shards" : 1
    },
    "analysis" : {
        "analyzer": {
            "an_analyzer": { "type" : "keyword" }
        }
    },
    "mappings" : {
        "a_type" : {
            "properties" : {
                "a_field" : { "type" : "string", "analyzer" : "an_analyzer" }
            }
        }
    }
}'
{"error":"MapperParsingException[mapping [a_type]]; nested: MapperParsingException[Analyzer [an_analyzer] not found for field [a_field]]; ","status":400}

Creating the index then putting the mapping works, but it is less convenient.

@clintongormley

This comment has been minimized.

Copy link
Member

clintongormley commented Feb 7, 2013

analysis should be passed in the settings section:

curl -XPUT 'http://127.0.0.1:9200/test2/?pretty=1'  -d '
{
   "mappings" : {
      "a_type" : {
         "properties" : {
            "a_field" : {
               "type" : "string",
               "analyzer" : "an_analyzer"
            }
         }
      }
   },
   "settings" : {
      "number_of_shards" : 1,
      "analysis" : {
         "analyzer" : {
            "an_analyzer" : {
               "type" : "keyword"
            }
         }
      }
   }
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment