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

Highlighting broken when query is on _all field or with prefixes #148

Closed
clintongormley opened this issue Apr 21, 2010 · 2 comments
Closed

Comments

@clintongormley
Copy link
Contributor

Hiya

Load this data:

curl -XPUT 'http://127.0.0.2:9200/es_test_1/'  -d '
{}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/'  -d '
{}
'
curl -XPUT 'http://127.0.0.2:9200/_all/type_1/_mapping'  -d '
{
   "_all" : {
      "store" : "yes",
      "term_vector" : "with_positions_offsets"
   },
   "properties" : {
      "num" : {
         "store" : "yes",
         "type" : "integer"
      },
      "date" : {
         "format" : "yyyy-MM-dd HH:mm:ss",
         "type" : "date"
      },
      "text" : {
         "store" : "yes",
         "type" : "string"
      }
   }
}
'
curl -XPUT 'http://127.0.0.2:9200/_all/type_2/_mapping'  -d '
{
   "_all" : {
      "store" : "yes",
      "term_vector" : "with_positions_offsets"
   },
   "properties" : {
      "num" : {
         "store" : "yes",
         "type" : "integer"
      },
      "date" : {
         "format" : "yyyy-MM-dd HH:mm:ss",
         "type" : "date"
      },
      "text" : {
         "store" : "yes",
         "type" : "string"
      }
   }
}
'
curl -XPOST 'http://127.0.0.2:9200/_refresh' 
curl -XGET 'http://127.0.0.2:9200/_cluster/health?timeout=2s&wait_for_status=green' 
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_1/1/_create'  -d '
{
   "num" : "2",
   "date" : "2010-04-2 00:00:00",
   "text" : "foo"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_2/2/_create'  -d '
{
   "num" : "3",
   "date" : "2010-04-3 00:00:00",
   "text" : "foo"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_1/3/_create'  -d '
{
   "num" : "4",
   "date" : "2010-04-4 00:00:00",
   "text" : "foo"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_2/4/_create'  -d '
{
   "num" : "5",
   "date" : "2010-04-5 00:00:00",
   "text" : "foo"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_1/5/_create'  -d '
{
   "num" : "6",
   "date" : "2010-04-6 00:00:00",
   "text" : "foo bar"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_2/6/_create'  -d '
{
   "num" : "7",
   "date" : "2010-04-7 00:00:00",
   "text" : "foo bar"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_1/7/_create'  -d '
{
   "num" : "8",
   "date" : "2010-04-8 00:00:00",
   "text" : "foo bar"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_2/8/_create'  -d '
{
   "num" : "9",
   "date" : "2010-04-9 00:00:00",
   "text" : "foo bar"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_1/9/_create'  -d '
{
   "num" : "10",
   "date" : "2010-04-10 00:00:00",
   "text" : "foo bar baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_2/10/_create'  -d '
{
   "num" : "11",
   "date" : "2010-04-11 00:00:00",
   "text" : "foo bar baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_1/11/_create'  -d '
{
   "num" : "12",
   "date" : "2010-04-12 00:00:00",
   "text" : "foo bar baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_2/12/_create'  -d '
{
   "num" : "13",
   "date" : "2010-04-13 00:00:00",
   "text" : "foo bar baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_1/13/_create'  -d '
{
   "num" : "14",
   "date" : "2010-04-14 00:00:00",
   "text" : "bar baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_2/14/_create'  -d '
{
   "num" : "15",
   "date" : "2010-04-15 00:00:00",
   "text" : "bar baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_1/15/_create'  -d '
{
   "num" : "16",
   "date" : "2010-04-16 00:00:00",
   "text" : "bar baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_2/16/_create'  -d '
{
   "num" : "17",
   "date" : "2010-04-17 00:00:00",
   "text" : "bar baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_1/17/_create'  -d '
{
   "num" : "18",
   "date" : "2010-04-18 00:00:00",
   "text" : "baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_2/18/_create'  -d '
{
   "num" : "19",
   "date" : "2010-04-19 00:00:00",
   "text" : "baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_1/19/_create'  -d '
{
   "num" : "20",
   "date" : "2010-04-20 00:00:00",
   "text" : "baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_2/20/_create'  -d '
{
   "num" : "21",
   "date" : "2010-04-21 00:00:00",
   "text" : "baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_1/21/_create'  -d '
{
   "num" : "22",
   "date" : "2010-04-22 00:00:00",
   "text" : "bar"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_2/22/_create'  -d '
{
   "num" : "23",
   "date" : "2010-04-23 00:00:00",
   "text" : "bar"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_1/23/_create'  -d '
{
   "num" : "24",
   "date" : "2010-04-24 00:00:00",
   "text" : "bar"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_2/24/_create'  -d '
{
   "num" : "25",
   "date" : "2010-04-25 00:00:00",
   "text" : "bar"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_1/25/_create'  -d '
{
   "num" : "26",
   "date" : "2010-04-26 00:00:00",
   "text" : "foo baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_2/26/_create'  -d '
{
   "num" : "27",
   "date" : "2010-04-27 00:00:00",
   "text" : "foo baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_1/27/_create'  -d '
{
   "num" : "28",
   "date" : "2010-04-28 00:00:00",
   "text" : "foo baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_2/28/_create'  -d '
{
   "num" : "29",
   "date" : "2010-04-29 00:00:00",
   "text" : "foo baz"
}
'

Then try these queries:

TERM QUERY: WORKS

curl -XGET 'http://127.0.0.2:9200/_all/_search'  -d '
{
   "query" : {
      "term" : {
         "text" : "foo"
      }
   },
   "highlight" : {
      "fields" : {
         "_all" : {}
      }
   },
   "size" : 2
}
'
# {
#    "hits" : {
#       "hits" : [
#          {
#             "_source" : {
#                "num" : "3",
#                "text" : "foo",
#                "date" : "2010-04-3 00:00:00"
#             },
#             "_index" : "es_test_1",
#             "_id" : "2",
#             "_type" : "type_2",
#             "highlight" : {
#                "_all" : [
#                   "00:00 <em>foo</em> "
#                ]
#             }
#          },
#          {
#             "_source" : {
#                "num" : "5",
#                "text" : "foo",
#                "date" : "2010-04-5 00:00:00"
#             },
#             "_index" : "es_test_2",
#             "_id" : "4",
#             "_type" : "type_2",
#             "highlight" : {
#                "_all" : [
#                   "00:00 <em>foo</em> "
#                ]
#             }
#          }
#       ],
#       "total" : 16
#    },
#    "_shards" : {
#       "failed" : 0,
#       "successful" : 10,
#       "total" : 10
#    }
# }

PREFIX QUERY: BROKEN

curl -XGET 'http://127.0.0.2:9200/_all/_search'  -d '
{
   "query" : {
      "prefix" : {
         "text" : "foo"
      }
   },
   "highlight" : {
      "fields" : {
         "_all" : {}
      }
   },
   "size" : 2
}
'
# {
#    "hits" : {
#       "hits" : [
#          {
#             "_source" : {
#                "num" : "5",
#                "text" : "foo",
#                "date" : "2010-04-5 00:00:00"
#             },
#             "_index" : "es_test_2",
#             "_id" : "4",
#             "_type" : "type_2",
#             "highlight" : {
#                "_all" : []
#             }
#          },
#          {
#             "_source" : {
#                "num" : "4",
#                "text" : "foo",
#                "date" : "2010-04-4 00:00:00"
#             },
#             "_index" : "es_test_2",
#             "_id" : "3",
#             "_type" : "type_1",
#             "highlight" : {
#                "_all" : []
#             }
#          }
#       ],
#       "total" : 16
#    },
#    "_shards" : {
#       "failed" : 0,
#       "successful" : 10,
#       "total" : 10
#    }
# }

QUERY STRING ON FIELD: WORKS

curl -XGET 'http://127.0.0.2:9200/_all/_search'  -d '
{
   "query" : {
      "query_string" : {
         "query" : "text:foo"
      }
   },
   "highlight" : {
      "fields" : {
         "_all" : {}
      }
   },
   "size" : 2
}
'
# {
#    "hits" : {
#       "hits" : [
#          {
#             "_source" : {
#                "num" : "3",
#                "text" : "foo",
#                "date" : "2010-04-3 00:00:00"
#             },
#             "_index" : "es_test_1",
#             "_id" : "2",
#             "_type" : "type_2",
#             "highlight" : {
#                "_all" : [
#                   "00:00 <em>foo</em> "
#                ]
#             }
#          },
#          {
#             "_source" : {
#                "num" : "5",
#                "text" : "foo",
#                "date" : "2010-04-5 00:00:00"
#             },
#             "_index" : "es_test_2",
#             "_id" : "4",
#             "_type" : "type_2",
#             "highlight" : {
#                "_all" : [
#                   "00:00 <em>foo</em> "
#                ]
#             }
#          }
#       ],
#       "total" : 16
#    },
#    "_shards" : {
#       "failed" : 0,
#       "successful" : 10,
#       "total" : 10
#    }
# }

QUERY STRING ON ALL: BROKEN
curl -XGET 'http://127.0.0.2:9200/_all/_search' -d '
{
"query" : {
"query_string" : {
"query" : "foo"
}
},
"highlight" : {
"fields" : {
"_all" : {}
}
},
"size" : 2
}
'
# {
# "hits" : {
# "hits" : [
# {
# "_source" : {
# "num" : "3",
# "text" : "foo",
# "date" : "2010-04-3 00:00:00"
# },
# "_index" : "es_test_1",
# "_id" : "2",
# "_type" : "type_2",
# "highlight" : {
# "_all" : []
# }
# },
# {
# "_source" : {
# "num" : "6",
# "text" : "foo bar",
# "date" : "2010-04-6 00:00:00"
# },
# "_index" : "es_test_1",
# "_id" : "5",
# "_type" : "type_1",
# "highlight" : {
# "_all" : []
# }
# }
# ],
# "total" : 16
# },
# "_shards" : {
# "failed" : 0,
# "successful" : 10,
# "total" : 10
# }
# }

@kimchy
Copy link
Member

kimchy commented Apr 25, 2010

hey, found the reason for this, working on a fix. Is there a reason there are two issues for this?

@kimchy
Copy link
Member

kimchy commented Apr 25, 2010

Highlighting broken when query is on _all field or with prefixes. Add also a flag to highlight to control if filters should be highlighted or not (called highlight_filters) which defaults to true. Closed by bf6cead.

tlrx added a commit that referenced this issue Jun 5, 2015
rmuir pushed a commit to rmuir/elasticsearch that referenced this issue Nov 8, 2015
We need to define `<elasticsearch.version>` in `pom.xml` as we now inherit from elasticsearch project parent pom.

But `elasticsearch.version` is set by default to `project.version` which is here `3.0.0-SNAPSHOT` for the mapper project.

Related to elastic#148
rmuir pushed a commit to rmuir/elasticsearch that referenced this issue Nov 8, 2015
Fix compiling issues.
Also fix test issues.

Need now to move old integration tests to RESTIT

Closes elastic#148.
This issue was closed.
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