Support for multifield

Multifield is not supported in the latest version yet. Is there any plan for supporting it?

If the question is “are we aware the feature is missing”, then yes: [HSEARCH-3465] - Hibernate JIRA

If the question is “when will it be added”, I don’t know. It will be when other, higher-priority tasks have been addressed and the team can have a look, or when an external contributor gives it a shot. Maybe you will? :wink:

At the moment, there’s an easy workaround: just use sibling fields instead of multifields.

E.g. instead of using this mapping:

{
  "mappings": {
      "properties": {
        "city": {
          "type": "text",
          "fields": {
            "raw": { 
              "type":  "keyword"
            }
          }
        }
      }
  }
}

… use this one:

@FullTextField
@KeywordField(name = "city_raw")
private String city;
{
  "mappings": {
      "properties": {
        "city": {
          "type": "text"
        },
        "city_raw": {
          "type": "keyword"
        }
      }
  }
}

It’s not perfect (it’s less elegant and there’s a slight network overhead), but internally (for indexing/search) it will mostly work the same.

1 Like

@yrodiere
Thank you for quick reply~!
I may contribute after I am good at Hibernate Search :slight_smile:

I know workaround that you mentioned.
But, I am concern that it may have 2 times more size (in point of storage view) because it adds one more same field.

Is it any difference in point of storage view(size) compared to multifield?

Yes, _source storage will take up more space. Index storage will be identical, though.

But I wouldn’t worry about storage space unless you actually see a problem. And if you do want to reduce disk usage, you can always configure more effective (but more CPU-expensive) compression: Index modules | Elasticsearch Guide [8.2] | Elastic .

See this part of the documentation to configure your Elasticsearch index through Hibernate Search.

1 Like