Copy_to field not searchable as I would expect

Here is my index:

{
  "settings": {
    "analysis": {
      "normalizer": {
        "keyword_lowercase": {
          "type": "custom",
          "filter": [
            "lowercase",
            "asciifolding"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "author_pub_fqdn": {
        "type": "keyword",
        "store": true
      },
      "author_string": {
        "type": "text",
        "store": true,
        "copy_to": "author_pub_fqdn",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256,
            "normalizer": "keyword_lowercase"
          }
        }
      },
      "collection": {
        "type": "long"
      },
      "collection_id": {
        "type": "long"
      },
      "processed": {
        "type": "boolean"
      },
      "publication_fqdn": {
        "type": "keyword",
        "copy_to": "author_pub_fqdn"
      },
      "use_in_article_search": {
        "type": "boolean"
      }
    }
  }
}

I have migrated a sample set of data from the old index. Here is a doc example:

{ - 
        "_index": "testing_v3",
        "_type": "_doc",
        "_id": "查看pdf原文finance.sina.com.cn544205",
        "_score": 1.5472039,
        "_source": { - 
          "collection_id": 544205,
          "author_string": "查看PDF原文",
          "publication_fqdn": "finance.sina.com.cn",
          "use_in_article_search": true
        }
      },

I want the copy_to on author_string and publication_fqdn so I can query them at the same time. I followed the example in the documentation. My copy_to field is author_pub_fqdn.

According to the docs, I should be able to query this doc using this query:

{
  "query": {
    "match": {
      "author_pub_fqdn": { 
        "query": "查看PDF原文 finance.sina.com.cn",
        "operator": "and"
      }
    }
  }
}

But I don't get any results.

I do get results if I query the author_pub_fqdn field for either the author_string or the publication_fqdn.

{
  "query": {
    "match": {
      "author_pub_fqdn": { 
        "query": "finance.sina.com.cn",
        "operator": "and"
      }
    }
  }
}
{
  "query": {
    "match": {
      "author_pub_fqdn": { 
        "query": "查看PDF原文",
        "operator": "and"
      }
    }
  }
}

Both of these find the doc so I know there must be data in the author_pub_fqdn field. I also tried making at the fields the same type (keyword), but still got the same results.

What happens if you make the copy_to field a text field?

That works! Thanks!

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