Search results: highlight property missing

Hello,

i have trouble getting highlight to work. Here is my script used for
testing:

init() {
curl -XDELETE http://localhost:9200/twitter
echo
curl -XPUT http://localhost:9200/twitter
echo

curl -XPUT http://localhost:9200/twitter/tweet/_mapping -d '{
    "tweet" : {
        "properties" : {
            "user" : { "type" : "string" },
            "message" : {
                "type" : "string",
                "index": "analyzed",
                "store": "yes",
                "term_vector" : "with_positions_offsets"
             }
        }
    }
}'
echo
curl -XPOST http://localhost:9200/twitter/tweet -d '{
    "user": "kimchy",
    "message": "You know, for Search"
}'
echo
curl -XPOST http://localhost:9200/twitter/tweet -d '{
    "user": "bar",
    "message": "You know, foo for Search"
}'
echo

sleep 2
echo '-------------------'

}

[ "$1" = "init" ] && init

curl -X GET 'http://localhost:9200/twitter/_search/?pretty=true' -d '{
"query":{
"query_string":{
"query":"foo"
}
}
},
"highlight":{
"pre_tags": "",
"post_tags": "
",
"fields" : {
"message" : {"number_of_fragments": 20}
}
}
}'

and here the output:
{"ok":true,"acknowledged":true}
{"ok":true,"acknowledged":true}
{"ok":true,"acknowledged":true}
{"ok":true,"_index":"twitter","_type":"tweet","_id":"aSAxiJwvTZCiAS0FV4Nnow"
,"_version":1}
{"ok":true,"_index":"twitter","_type":"tweet","_id":"pTYsw0FWQYOUMtzRAD7gSg"
,"_version":1}

{
"took" : 6,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.09492774,
"hits" : [ {
"_index" : "twitter",
"_type" : "tweet",
"_id" : "pTYsw0FWQYOUMtzRAD7gSg",
"_score" : 0.09492774, "_source" : {
"user": "bar",
"message": "You know, foo for Search"
}
} ]
}
}%

as you can see there are no errors but the highlight property isn't there,
too.
Can someone see my mistake?

Regards,
Herman Fries

--

OK mistake found. Sorry for the noise.

I had to many closing brackets so highlight part of the query got ignored.
I didn't know you can add more closing brackets without causing parser
errors. :slight_smile:

Am Donnerstag, 17. Januar 2013 13:56:56 UTC+1 schrieb Herman Fries:

Hello,

i have trouble getting highlight to work. Here is my script used for
testing:

init() {
curl -XDELETE http://localhost:9200/twitter
echo
curl -XPUT http://localhost:9200/twitter
echo

curl -XPUT http://localhost:9200/twitter/tweet/_mapping -d '{
    "tweet" : {
        "properties" : {
            "user" : { "type" : "string" },
            "message" : {
                "type" : "string",
                "index": "analyzed",
                "store": "yes",
                "term_vector" : "with_positions_offsets"
             }
        }
    }
}'
echo
curl -XPOST http://localhost:9200/twitter/tweet -d '{
    "user": "kimchy",
    "message": "You know, for Search"
}'
echo
curl -XPOST http://localhost:9200/twitter/tweet -d '{
    "user": "bar",
    "message": "You know, foo for Search"
}'
echo

sleep 2
echo '-------------------'

}

[ "$1" = "init" ] && init

curl -X GET 'http://localhost:9200/twitter/_search/?pretty=true' -d '{
"query":{
"query_string":{
"query":"foo"
}
}
},
"highlight":{
"pre_tags": "",
"post_tags": "
",
"fields" : {
"message" : {"number_of_fragments": 20}
}
}
}'

and here the output:
{"ok":true,"acknowledged":true}
{"ok":true,"acknowledged":true}
{"ok":true,"acknowledged":true}
{"ok":true,"_index":"twitter","_type":"tweet","_id":
"aSAxiJwvTZCiAS0FV4Nnow","_version":1}
{"ok":true,"_index":"twitter","_type":"tweet","_id":
"pTYsw0FWQYOUMtzRAD7gSg","_version":1}

{
"took" : 6,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.09492774,
"hits" : [ {
"_index" : "twitter",
"_type" : "tweet",
"_id" : "pTYsw0FWQYOUMtzRAD7gSg",
"_score" : 0.09492774, "_source" : {
"user": "bar",
"message": "You know, foo for Search"
}
} ]
}
}%

as you can see there are no errors but the highlight property isn't there,
too.
Can someone see my mistake?

Regards,
Herman Fries

--

Move the Highlight section above the query:

curl -X GET 'http://localhost:9200/twitter/_search/?pretty=true' -d '{

 "highlight":{
    "pre_tags": "<b>",
    "post_tags": "</b>",
    "fields" : {
        "message" : {"number_of_fragments": 20}
    }
},
 "query":{
        "query_string":{
            "query":"foo"
        }
    }
},

}'
{
"took" : 11,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.13424811,
"hits" : [ {
"_index" : "twitter",
"_type" : "tweet",
"_id" : "mSr21FwJRT-71SDCnRaEKw",
"_score" : 0.13424811, "_source" : {
"user": "bar",
"message": "You know, foo for Search"
},
"highlight" : {
"message" : [ "know, foo for Search" ]
}
} ]
}
}

On Thursday, January 17, 2013 7:56:56 AM UTC-5, Herman Fries wrote:

Hello,

i have trouble getting highlight to work. Here is my script used for
testing:

init() {
curl -XDELETE http://localhost:9200/twitter
echo
curl -XPUT http://localhost:9200/twitter
echo

curl -XPUT http://localhost:9200/twitter/tweet/_mapping -d '{
    "tweet" : {
        "properties" : {
            "user" : { "type" : "string" },
            "message" : {
                "type" : "string",
                "index": "analyzed",
                "store": "yes",
                "term_vector" : "with_positions_offsets"
             }
        }
    }
}'
echo
curl -XPOST http://localhost:9200/twitter/tweet -d '{
    "user": "kimchy",
    "message": "You know, for Search"
}'
echo
curl -XPOST http://localhost:9200/twitter/tweet -d '{
    "user": "bar",
    "message": "You know, foo for Search"
}'
echo

sleep 2
echo '-------------------'

}

[ "$1" = "init" ] && init

curl -X GET 'http://localhost:9200/twitter/_search/?pretty=true' -d '{
"query":{
"query_string":{
"query":"foo"
}
}
},
"highlight":{
"pre_tags": "",
"post_tags": "
",
"fields" : {
"message" : {"number_of_fragments": 20}
}
}
}'

and here the output:
{"ok":true,"acknowledged":true}
{"ok":true,"acknowledged":true}
{"ok":true,"acknowledged":true}
{"ok":true,"_index":"twitter","_type":"tweet","_id":
"aSAxiJwvTZCiAS0FV4Nnow","_version":1}
{"ok":true,"_index":"twitter","_type":"tweet","_id":
"pTYsw0FWQYOUMtzRAD7gSg","_version":1}

{
"took" : 6,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.09492774,
"hits" : [ {
"_index" : "twitter",
"_type" : "tweet",
"_id" : "pTYsw0FWQYOUMtzRAD7gSg",
"_score" : 0.09492774, "_source" : {
"user": "bar",
"message": "You know, foo for Search"
}
} ]
}
}%

as you can see there are no errors but the highlight property isn't there,
too.
Can someone see my mistake?

Regards,
Herman Fries

--

Ah, or closing brackets. Whoops! Ignore my response =)

-Zach

On Thursday, January 17, 2013 7:56:56 AM UTC-5, Herman Fries wrote:

Hello,

i have trouble getting highlight to work. Here is my script used for
testing:

init() {
curl -XDELETE http://localhost:9200/twitter
echo
curl -XPUT http://localhost:9200/twitter
echo

curl -XPUT http://localhost:9200/twitter/tweet/_mapping -d '{
    "tweet" : {
        "properties" : {
            "user" : { "type" : "string" },
            "message" : {
                "type" : "string",
                "index": "analyzed",
                "store": "yes",
                "term_vector" : "with_positions_offsets"
             }
        }
    }
}'
echo
curl -XPOST http://localhost:9200/twitter/tweet -d '{
    "user": "kimchy",
    "message": "You know, for Search"
}'
echo
curl -XPOST http://localhost:9200/twitter/tweet -d '{
    "user": "bar",
    "message": "You know, foo for Search"
}'
echo

sleep 2
echo '-------------------'

}

[ "$1" = "init" ] && init

curl -X GET 'http://localhost:9200/twitter/_search/?pretty=true' -d '{
"query":{
"query_string":{
"query":"foo"
}
}
},
"highlight":{
"pre_tags": "",
"post_tags": "
",
"fields" : {
"message" : {"number_of_fragments": 20}
}
}
}'

and here the output:
{"ok":true,"acknowledged":true}
{"ok":true,"acknowledged":true}
{"ok":true,"acknowledged":true}
{"ok":true,"_index":"twitter","_type":"tweet","_id":
"aSAxiJwvTZCiAS0FV4Nnow","_version":1}
{"ok":true,"_index":"twitter","_type":"tweet","_id":
"pTYsw0FWQYOUMtzRAD7gSg","_version":1}

{
"took" : 6,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.09492774,
"hits" : [ {
"_index" : "twitter",
"_type" : "tweet",
"_id" : "pTYsw0FWQYOUMtzRAD7gSg",
"_score" : 0.09492774, "_source" : {
"user": "bar",
"message": "You know, foo for Search"
}
} ]
}
}%

as you can see there are no errors but the highlight property isn't there,
too.
Can someone see my mistake?

Regards,
Herman Fries

--