1

I use elasticsearch a lot at work (from Python) but wanted to roll it into a little .Net project I'm doing in my spare time. A quick wander through NuGet brought me to Nest.

I'm defining my "model" as follows...

<ElasticType(Name:="Document")>
Public Class Document
    Property UserId As Long
    <ElasticProperty(IndexAnalyzer:="not_analyzed")>
    Property Something As String
    Property EmailAddress As String
End Class

and then attempting to create and index like this...

Dim Ret = ES.CreateIndex(IndexName,
               Function(x) x.AddMapping(Of Document)(
                   Function(m) m.MapFromAttributes))
If Not Ret.OK Then
    With Ret.ConnectionStatus.Error
        Throw New Exception(String.Format("Failed to create index ({0}): {1}", .HttpStatusCode, .ExceptionMessage))
    End With
End If

And I'm getting Failed to create index (BadRequest): MapperParsingException[mapping [Document]]; nested: MapperParsingException[Analyzer [not_analyzed] not found for field [something]];

I've tried both

<ElasticProperty(Analyzer:="not_analyzed")>

and

<ElasticProperty(IndexAnalyzer:="not_analyzed")>

What I'm trying to get it to build is json equivalent to

"something" : {"type" : "string", "index" : "not_analyzed"}

as shown in the es docs.

What am I missing?

(Elastic 0.90.6)

2
  • 1
    Can you post the actual http request that is made to the elasticsearch server along with the query parameters? Commented Nov 7, 2013 at 12:29
  • @geeky_sh I've just found where that's stored (I hadn't spotted it before) and You've pointed me in the right direction. Thank you! I'll post details as an answer Commented Nov 7, 2013 at 13:21

1 Answer 1

3

There was an attribute property I missed which handles this...

<ElasticType(Name:="Document")>
Public Class Document
    Property UserId As Long
    <ElasticProperty(Index:=FieldIndexOption.not_analyzed)>
    Property Something As String
    Property EmailAddress As String
End Class

Note the Index property which takes an Enum. Thanks to @geeky_sh for prompting me to look in the right place.

Sign up to request clarification or add additional context in comments.

1 Comment

Elasticsearch log file will complain with: Caused by: org.elasticsearch.index.mapper.MapperParsingException: Analyzer [not_analyzed] not found for field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.