Cross field search with different analyzers

I have the following (simplified) mapping:

{
"settings": {
    "index": {
        "number_of_shards": "2",
        "number_of_replicas": "1"
    },
    "analysis": {
        "analyzer": {
            "rebuilt_whitespace": {
                "tokenizer": "whitespace",
                "filter": ["lowercase"]
            }
        }
    }
},
"mappings": {
    "properties": {
        "tags": {
            "fielddata": true,
            "type": "text",
            "analyzer": "rebuilt_whitespace",
            "fields": {
                "length": {
                    "type": "token_count",
                    "analyzer": "rebuilt_whitespace"
                }
            }
        },
        "category": {
            "type": "text",
            "fields": {
                "raw": {
                    "type": "keyword"
                }
            }
        }
    }
}
}

Say I have a query like "c++ programming" I'd like to be able to have results that match "programming" in category and "c++" in tags (but not "c"). Using cross_fields (with multi_match or query_string) to do this doesn't work as they are using different analyzers. Anything else I have been able to find seem to go on compromise on something else. Also note I have more fields than those listed here, so doing "exhaustive" matching won't work.
Basically I want to be able to perform:

+(tags:programming | category:programming) +(tags:c++ | category:c)

Note the different analyzers used for "c++". Is this possible?

I haven't found a solution to this. Some threads a mentioning using query_string with default_operatorset to AND, but this is still not giving me the right results.
Alternatively, I can set search_analyzer at query time to force them into the same groups, but this is not optimal either.
Any advice is greatly appreciated!

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