In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you how to achieve Elasticsearch Percolate reverse retrieval, the content is concise and easy to understand, can definitely brighten your eyes, through the detailed introduction of this article, I hope you can get something.
Let's explore the usage, principle and applicable scenarios of percolator query. 1. What is a percolator query
Chinese meaning of percolator: infiltrator.
Percolator query is equivalent to pervasive query or reverse query.
We believe that most Elasticsearch developers will follow the convention of thinking, and we model the data and store it in the index. They then retrieve these documents by searching the API definition query.
The principle of percolator query is exactly the opposite, as shown in the following figure:
You store queries in an index and then define documents through Percolate API to retrieve them.
That is:
The traditional query returns the document according to the query conditions of the query statement. Query- > document. On the other hand, percolator infiltrates the query and returns the query statement that matches it according to the document. Document- > query. 2. Application scenario of percolator query
Example: provide a platform to store user interests so that the correct content (notification alert) is sent to the right user each time new content enters.
For example: users subscribe to a specific topic so that once a new article on that topic appears, a notification is sent to interested users.
The application scenarios are as follows:
Price monitoring news alert stock warning log monitoring weather forecast inventory warning. 3. Actual combat 3.1 actual business requirements
Threshold alarm business scenario-an alarm prompt when the value of the specified field count is greater than the threshold.
3.2 percolator mapping definition DELETE my-index
PUT / my-index
{
"mappings": {
"properties": {
"threshold": {
"type": "long"
}
"count": {
"type": "long"
}
"query": {
"type": "percolator"
}
}
}
}
Note: percolator is the equivalent of: keyword, long, Integer.
"query": {
"type": "percolator"
}
This definition structure cannot be modified.
Insert document PUT / my-index/_doc/1
{
"threshold":
"query": {
"bool": {
"must": {
"range": {
"count": {
"gt":
}
}
}
}
}
}
3.4 query implementation of GET / my-index/_search
{
"query": {
"percolate": {
"field": "query"
"documents": [
{
"count": 1
}
{
"count": 50
}
{
"count":
}
{
"count":
}
]
}
}
}
Return the result (part):
{
"took": 4
. Omit.
}
"fields": {
"_ percolator_document_slot": [
two,
three
]
}
}
]
}
}
Where "_ percolator_document_slot" refers to the document position, counting from 0.
4. How to implement percolator query?
First: by using DSL to construct the user's warning condition to be set into an Elasticsearch query statement, as if it were a document, import the Elasticsearch index.
Second: every time a new article is published, it can be filtered without indexing it to see if the document value has reached the threshold.
Third, according to the returned result _ percolator_document_slot, decide whether early warning and accurate value early warning.
The above content is how to achieve Elasticsearch Percolate reverse retrieval, have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.