elastic_tutorial/The Elasticsearch Documentation/3_Medium/2_Search.es
2025-04-09 09:37:23 +03:30

74 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

///
POST firstindex/_search
{
"size": 4,
"from": 4,
"_source": [
"username",
"age"
],
"query": {
"match_all": {}
}
}
// size : 4
// فقط 4 تا از اولی ها را برگردان
// from: 4
// از 4 شروع کن
// فقط فیلد های age و username را بر گردان
POST qanonindex-v03/_search
{
"size": 4,
"from": 4,
"_source": ["username", "age"],
"query": {
"bool": {
"must": [
{
"term": {
"username": "Ali"
}
},
{
"match": {
"age": "23"
}
}
]
}
}
}
// bool
// استفاده از query های ترکیبی(فلان شرط و فلان شرط - فلان شرط یا فلان شرط)
// must -> array
// مجموعه ای از شرط ها که همه شان باید برقرار باشد تا برگردد
GET /firstindex/_search
{
"query" : {
"ids" : {
"values": ["User1", "User12", "User13"]
}
}
}
// بر گرداندن تمام آی دی های تعریف شده(این دستور سرچ است و 404 نمیدهد)
// Note: به ترتیب نیستند
GET /firstindex/_search
{
"query": {
"range" : {
"id" : {
"lte" : 20
}
}
}
}
// کلمه id میگوید میخواهم با آی دی سرچ کنم
// کلمه lte به معنای کمتر یا مساوی است
// یعنی معنای این query میشود هر id که کمتر یا مساوی با عدد 20 باشد
// برعکس gte