Tuesday, May 1, 2018
Elastic Search Example: Part 2
Donghuas-MacBook-Air:elasticsearch-6.2.4 donghua$ curl -XGET -H 'Content-Type: application/json' -u elastic:elastic 'localhost:9200/blogs/_search?pretty' -d '{
> "query" : {
> "match" : {
> "user" : "donghua"
> }
> }
> }'
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 0.2876821,
"hits" : [
{
"_index" : "blogs",
"_type" : "post",
"_id" : "2",
"_score" : 0.2876821,
"_source" : {
"Title" : "title 2",
"Body" : "blog, blog blogs",
"user" : "donghua",
"date" : "1/5/2018"
}
},
{
"_index" : "blogs",
"_type" : "post",
"_id" : "1",
"_score" : 0.2876821,
"_source" : {
"Title" : "title 1",
"Body" : "blog, blog",
"user" : "donghua",
"date" : "1/5/2018"
}
}
]
}
}
Donghuas-MacBook-Air:elasticsearch-6.2.4 donghua$ curl -XGET -H 'Content-Type: application/json' -u elastic:elastic 'localhost:9200/blogs/_search?pretty' -d '{
> "query" : {
> "match_all" : {}
> }
> }'
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 3,
"max_score" : 1.0,
"hits" : [
{
"_index" : "blogs",
"_type" : "post",
"_id" : "M1i9GGMBNSS82bObMFNL",
"_score" : 1.0,
"_source" : {
"Title" : "title 3",
"Body" : "blog without docid",
"user" : "donghua2",
"date" : "1/5/2018"
}
},
{
"_index" : "blogs",
"_type" : "post",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"Title" : "title 2",
"Body" : "blog, blog blogs",
"user" : "donghua",
"date" : "1/5/2018"
}
},
{
"_index" : "blogs",
"_type" : "post",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"Title" : "title 1",
"Body" : "blog, blog",
"user" : "donghua",
"date" : "1/5/2018"
}
}
]
}
}
Donghuas-MacBook-Air:elasticsearch-6.2.4 donghua$
Donghuas-MacBook-Air:elasticsearch-6.2.4 donghua$ curl -XGET -H 'Content-Type: application/json' -u elastic:elastic 'localhost:9200/blogs/_search?pretty' -d '{
> "query" : {
> "match" : {
> "user" : "DONGHUA DONGHUA2"
> }
> }
> }'
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 3,
"max_score" : 0.2876821,
"hits" : [
{
"_index" : "blogs",
"_type" : "post",
"_id" : "M1i9GGMBNSS82bObMFNL",
"_score" : 0.2876821,
"_source" : {
"Title" : "title 3",
"Body" : "blog without docid",
"user" : "donghua2",
"date" : "1/5/2018"
}
},
{
"_index" : "blogs",
"_type" : "post",
"_id" : "2",
"_score" : 0.2876821,
"_source" : {
"Title" : "title 2",
"Body" : "blog, blog blogs",
"user" : "donghua",
"date" : "1/5/2018"
}
},
{
"_index" : "blogs",
"_type" : "post",
"_id" : "1",
"_score" : 0.2876821,
"_source" : {
"Title" : "title 1",
"Body" : "blog, blog",
"user" : "donghua",
"date" : "1/5/2018"
}
}
]
}
}
Donghuas-MacBook-Air:elasticsearch-6.2.4 donghua$
Donghuas-MacBook-Air:elasticsearch-6.2.4 donghua$ curl -XGET -H 'Content-Type: application/json' -u elastic:elastic 'localhost:9200/blogs/_search?pretty' -d '{
> "query" : {
> "multi_match" : {
> "fields" : ["user","Body"],
> "query" : "docid"
> }
> }
> }'
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.2876821,
"hits" : [
{
"_index" : "blogs",
"_type" : "post",
"_id" : "M1i9GGMBNSS82bObMFNL",
"_score" : 0.2876821,
"_source" : {
"Title" : "title 3",
"Body" : "blog without docid",
"user" : "donghua2",
"date" : "1/5/2018"
}
}
]
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment