Field that is searchable and sortable (5.2)


(cmalpeli) #1

Hello I am trying to make a text field both searchable and sortable. I have a normalizer that seems to handle the sorting, but it prevents the field from being searchable. Any ideas what I've done wrong - note this is in Searchkick (ruby gem) format:

 settings: {
      analysis: {
        normalizer: {
          case_insensitive_sort: {
            type: "custom",
            char_filter: [],
            filter: ['lowercase', 'asciifolding']
          }
        }
      }
    },
    merge_mappings: true, 
    mappings: {
      employer: {
        properties: {
          name: {
            type: 'text',
            fields: {
              sort: {
                type: 'keyword',
                ignore_above: 256,
                normalizer: 'case_insensitive_sort'
              }
            }
          }
        } 
      }
    }

(Thiago Souza) #2

A field can not be both sortable and searchable because sorting happens on term level and a searchable field has many terms for a single value.

But the mapping you have presented is the solution for this issue, you have a multi-field in which you would search on field name but sort on field name.sort. Isn't that what you want?


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.