Copy_to properties isn't queriable

Hi. I've got a puzzling question here. This is the definition for my index:

"mappings": {
    "properties": {
        "name_copy": {
            "type": "text"
        },
        "name": {
            "type": "text",
            "copy_to": "name_copy"
        }
    }
}

I've simplified that definition a little bit to highlight just the fields I'm testing.

If I populate my index and run the following search against it, I get 158 hits:

{
    "query": {
        "match" : {
            "name" : "organic"
        }
    }
}

The following query returns zero hits:

{
    "query": {
        "match" : {
            "name_copy" : "organic"
        }
    }
}

Those two queries should be identical, correct? The field name_copy should just have the text that is in name in it. So, querying one should be the same as querying the other.

What am I doing wrong? How would you go about troubleshooting this?

Thanks in advance.

I did not check the example you just sent but I guess it gives the correct results.
So I'd then check the actual mapping, the analyzers...

If you could provide a script which does not match, that'd help to troubleshoot this.

Yeah, the copy_to was a red herring. Ultimately the issue was that in my mapping, I had a complex datatype errantly marked as nested instead of object.

Thanks for taking a look at it!

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