I'm using Elasticsearch 5.5, below are the index on Elasticsearch
[
{
"_index" : "corpindex-qa",
"_type" : "corpdocs-qa",
"_id" : "5cb468fd35b9db6f2235e4c4",
"_score" : 1.0,
"_source" : {
"Edition" : {
"Values" : {
"title" : "new featured parallex"
}
},
"url" : "/demo-inline-component-capability/demo-of-featured-parallex",
"year" : 2019,
"author" : "",
"docdef" : "new-featured-parallex-reference-1"
}
},
{
"_index" : "corpindex-qa",
"_type" : "corpdocs-qa",
"_id" : "5ccfe1dd6948151485158661",
"_score" : 1.0,
"_source" : {
"Edition" : {
"Values" : {
"title" : "demo of event careers",
"description" : "careers"
}
},
"url" : "/demo-inline-component-capability/demo-of-event-card",
"year" : 2019,
"author" : "",
"docdef" : "inline-event-card"
}
}]
Trying to get the documents by using query with terms on nodejs with elasticsearch client module.
client.search({
index: searchIndex,
type: searchType
, body: {
query: {
terms: {
"url": ["/demo-inline-component-capability/demo-of-featured-parallex","/demo-inline-component-capability/demo-of-event-card"]
}
}
}
});
getting zero document while performing above.
{"took":0,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}
Here is the mapping details, which took it from elasticsaerch
{
corpindex-qa: {
aliases: { },
mappings: {
corpdocs-qa: {
properties: {
url: {
type: "text",
fields: {
keyword: {
type: "keyword",
ignore_above: 256
}
}
},
year: {
type: "long"
}
}
}
},
settings: {
index: {
creation_date: "1559900006341",
number_of_shards: "5",
number_of_replicas: "1",
uuid: "xL6PICFARZq6zMZBpm-75A",
version: {
created: "5050399"
},
provided_name: "corpindex-qa"
}
}
}
}
Please share your thoughts that would helpful to me.
Since you are trying to match exact url
use url.keyword
instead of url
. Update your query to below:
client.search({
index: searchIndex,
type: searchType
, body: {
query: {
terms: {
"url.keyword": ["/demo-inline-component-capability/demo-of-featured-parallex","/demo-inline-component-capability/demo-of-event-card"]
}
}
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.