-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Specifying .Analyzer in mapping destroys the GeoPoint mapping. #2498
Comments
Hi @daluas I'm having trouble trying to reproduce this. Specifying the mapping with and without In your example snippet I see you're initializing with |
Hi, This is the method that initializes the client: private const string usersIndex = "users"; private void ConfigureElastiClient()
I'm using this method to insert users in Elastic Search: private void AddToElasticSearch(UserSearchEntity line) and below is my User class: public class UserSearchEntity
Commented out the .Analyzer("whitespace") line in the initialization method is doing the "location":{"type":"geo_point"} mapping. Having this line as uncommented performs "location":{"properties":{"lat":{"type":"float"},"lon":{"type":"float"}}} mapping. |
@daluas still not able to reproduce this. What is the value of Also, I'd like to suggest a few other improvements:
Try this instead: elasticClient.CreateIndex(usersIndex, i => i
.Mappings(ms => ms
.Map<UserSearchEntity>(m => m
.AutoMap()
.Analyzer("whitespace")
)
)
) Also, as mentioned above, specify elasticClient.Index(line, idx => idx.Index(userIndex)); Let me know if that helps. |
Hello, I tried to do it as you indicated...but...elasticClient.CreateIndex method returns an error: {Type: mapper_parsing_exception Reason: "Failed to parse mapping [usersearchentity]: Root mapping definition has unsupported parameters: [analyzer : whitespace]" CausedBy: "Type: mapper_parsing_exception Reason: "Root mapping definition has unsupported parameters: [analyzer : whitespace]""} As I mentioned: elasticClient.CreateIndex fails with the error...but...elasticClient.Index(line, idx => idx.Index(usersIndex)); is working and creates the mappings I mentioned in this issue. |
Ah, makes sense now :) The create index request is failing because analyzers are no longer supported at the type level. See elastic/elasticsearch#8874 Unfortunately, we never removed this methods from the client, but I just opened #2506 which marks them obsolete. You should set the Since the index creation was failing, your indexing requests created an index and dynamic mapping on the fly, which defaults |
Hi, I've changed my class like this: public class UserSearchEntity
but the SearchAnalyzer seems to not work. Any thoughts about this? |
@daluas what is the query you use to search for |
It's fixed now. A colleague of you helped me and indicated that I have to specify the field in order to used the whitespace analyzer...otherwise the _all fields will be used and it uses the simple analyzer. |
Did you ever solve this? |
Yes. As I indicated, the field used for whitespace analyzer should be specified, otherwise, all fields will be used. When all fields are used, the simple analyzer is in place. |
Thank you for your reply - but I don't understand what the analyzer has to do with the mapping issue of Can you provide a pseudo-ish code example? Thanks in advance. |
Is your problem related to the GeoPoint mappings? |
NEST/Elasticsearch.Net version: 5.0.0.0
Elasticsearch version:
"version" : {
"number" : "5.1.1",
"build_hash" : "5395e21",
"build_date" : "2016-12-06T12:36:15.409Z",
"build_snapshot" : false,
"lucene_version" : "6.3.0"
}
Description of the problem including expected versus actual behavior:
Specify the .Analyzer property in CreateIndex -> .Mappings section, crete a strange mapping:
"location":{"properties":{"lat":{"type":"float"},"lon":{"type":"float"}}}
If I'm omitting the .Analyzer and let the NEST select its default analyzer, in that case, the GeoPoint filed is correctly mapped as expected: "location":{"type":"geo_point"}
Provide
ConnectionSettings
(if relevant):elasticClient.CreateIndex(usersIndex, i => indexDescriptor
.InitializeUsing(indexDescriptor)
.Mappings(ms => ms.Map(m => m.AutoMap()
.Properties(prop => prop.GeoPoint(geo => geo.Name(g => g.Location)))
//.Analyzer("whitespace")
))
);
The text was updated successfully, but these errors were encountered: