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

77 lines
1.9 KiB
JavaScript
Raw Permalink 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.

GET firstindex/_count
// تعداد doc های insert شده در index
GET /firstindex/_doc/1
// گرفتن اطلاعات doc با id 1
GET firstindex/_doc/1/_source
// گرفتن مقادیر داخل doc با id 1
GET /firstindex/_search
{
"_source": ["field1", "username", "age"], // فیلدهای مورد نظر خود را در اینجا قرار دهید
"query": {
// your query, Exaple:
"match_all": {}
}
}
// با این کار field های 1 و فیلد یوسر نیم و age همه برگردانده میشود
// با توجه به این که فیلدی به نام field1 نداریم، اروری دریافت نمیشود
GET /firstindex/_search
{
"query": {
"match": {
"username": "123"
}
}
}
// هرکجا که username Ali باشد را برمیگرداند
// این جستجوی دقیق نیست و از پردازش متن و دیگر settings ها استفاده میکند
// در ضمن مقادیری مانند Aliases نیز بر گردانده میشوند
// چون جستجو است 404 نمیدهد
GET /firstindex/_search
{
"query": {
"term": {
"username": "Ali"
}
}
}
// هرکجا که username Ali باشد را برمیگرداند
// این جستجوی دقیق است و از پردازش متن و دیگر settings ها استفاده نمیکند
// مثلا برعکس دستور قبلی، Aliases را نمیگیرد
GET /firstindex/_search
{
"query": {
"range" : {
"id" : {
"gte" : 20
}
}
}
}
// کلمه id میگوید میخواهم با آی دی سرچ کنم
// کلمه gte به معنای بیشتر یا مساوی است
// یعنی معنای این query میشود هر id که بیشتر یا مساوی با عدد 20 باشد
GET /index_name/_search
{
"_source": "*",
"query": {
"match_all": {}
}
}
// تمام فیلد ها