grails / elasticsearch-grails-plugin

The Elasticsearch Grails plugin
https://grails-plugins.github.io/elasticsearch-grails-plugin/
Other
15 stars 23 forks source link

Properties mapping of string fields to ES type keyword not working as expected #170

Open temi opened 2 years ago

temi commented 2 years ago

Expected Behavior

Class Test {
    String name
    static searchable = {
        name index: "true"
    }
}

The above code's mapped ES type should be keyword. But the code maps to text.

Actual Behaviour

The above code maps to type text.

Steps To Reproduce

No response

Environment Information

Example Application

No response

Version

4

temi commented 2 years ago

The issue seems to be in the below code found in SearchableClassPropertyMapping

    boolean isAnalyzed() {
        String index = (String) mappingAttributes.index
        (index == null || index)
    }

The below table shows how the code works.

property value value value
index "true" "false" null
isAnalyzed true true true
ES type "text" "text" "text"

The code should work like below.

property value value value
index "true" "false" null
isAnalyzed false true true
ES type "keyword" "text" "text"