Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

highlight.fields should accept field names with the full path #1192

Closed
clintongormley opened this issue Aug 2, 2011 · 0 comments
Closed

Comments

@clintongormley
Copy link

When specifying fields to highlight, you have to specify the simple field name - you can't specify the full path eg body not foo.body:

curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1'  -d '
{
   "mappings" : {
      "foo" : {
         "properties" : {
            "text" : {
               "type" : "string"
            }
         }
      }
   }
}
'

curl -XPOST 'http://127.0.0.1:9200/test/foo?pretty=1'  -d '
{
   "text" : "the quick brown fox jumped over the lazy dog"
}
'

Simple field name:

curl -XGET 'http://127.0.0.1:9200/test/_search?pretty=1'  -d '
{
   "query" : {
      "text" : {
         "text" : "brown"
      }
   },
   "highlight" : {
      "fields" : {
         "text" : {}
      }
   }
}
'

# {
#    "hits" : {
#       "hits" : [
#          {
#             "_source" : {
#                "text" : "the quick brown fox jumped over the lazy
# >                 dog"
#             },
#             "_score" : 0.11506981,
#             "_index" : "test",
#             "_id" : "SA4FtDBxTq6Gk-k8uqGcag",
#             "_type" : "foo",
#             "highlight" : {
#                "text" : [
#                   "the quick <em>brown</em> fox jumped over the l
# >                   azy dog"
#                ]
#             }
#          }
#       ],
#       "max_score" : 0.11506981,
#       "total" : 1
#    },
#    "timed_out" : false,
#    "_shards" : {
#       "failed" : 0,
#       "successful" : 5,
#       "total" : 5
#    },
#    "took" : 2
# }

Full path:

curl -XGET 'http://127.0.0.1:9200/test/_search?pretty=1'  -d '
{
   "query" : {
      "text" : {
         "foo.text" : "brown"
      }
   },
   "highlight" : {
      "fields" : {
         "foo.text" : {}
      }
   }
}
'

# {
#    "hits" : {
#       "hits" : [
#          {
#             "_source" : {
#                "text" : "the quick brown fox jumped over the lazy
# >                 dog"
#             },
#             "_score" : 0.11506981,
#             "_index" : "test",
#             "_id" : "SA4FtDBxTq6Gk-k8uqGcag",
#             "_type" : "foo"
#          }
#       ],
#       "max_score" : 0.11506981,
#       "total" : 1
#    },
#    "timed_out" : false,
#    "_shards" : {
#       "failed" : 0,
#       "successful" : 5,
#       "total" : 5
#    },
#    "took" : 1
# }
@kimchy kimchy closed this as completed in a0bbb54 Aug 2, 2011
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
williamrandolph pushed a commit to williamrandolph/elasticsearch that referenced this issue Jun 4, 2020
Additionally, the scaled float should be treated as a double value in
Hadoop.

Fixes elastic#1192, fixes elastic#1074
jev001 pushed a commit to jev001/elasticsearch that referenced this issue Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants