使用elasticsearch过滤器索引时,有没有办法提高内存性能?
我为我的过滤器创建了一个单独的索引.我有大约1 000 000个用户创建的已保存搜索(用于电子邮件警报).创建此过滤器索引后,我的堆使用率达到100%,服务器对任何查询都没有响应.我的资源有限,我不能简单地在这个问题上投入更多内存.唯一的解决方案是删除包含我保存的搜索的索引.
根据我的阅读,过滤器索引永久驻留在内存中.这完全是必要的吗?有没有办法限制这种行为,但仍保留功能?有没有办法优化我的数据/查询/索引结构,以避免这种行为,同时仍然实现所需的结果?
我们通常做的就是索引文档并通过查询返回它们。简而言之,渗透器允许执行的操作是索引查询并根据索引查询渗透文档以了解它们匹配哪些查询。也称为反向搜索。
可以在 PostgreSQL 中渗透吗?
我们正在 ElasticSearch 中使用过滤器,我们需要通过短语而不是逐字获得完整的突出显示:
例如,我们有下一个搜索:
curl -X GET "localhost:9200/my-index/_search" -H 'Content-Type: application/json' -d'
{
"query" : {
"percolate" : {
"field": "query",
"document" : {
"title" : "A new bonsai tree in the office and jungle. The enojen tree in a kerojen."
}
}
},
"highlight": {
"fields": {
"title": {}
}
}
}
'
Run Code Online (Sandbox Code Playgroud)
我们得到下一个输出:
{
"took":12,
"timed_out":false,
"_shards":{
"total":5,
"successful":5,
"skipped":0,
"failed":0
},
"hits":{
"total":45,
"max_score":2.1576157,
"hits":[
{
"_index":"my-index",
"_type":"_doc",
"_id":"2",
"_score":2.1576157,
"_source":{
"query":{
"match":{
"title":"the enojen tree in …Run Code Online (Sandbox Code Playgroud) 指数:
{
"settings": {
"index.percolator.map_unmapped_fields_as_text": true,
},
"mappings": {
"properties": {
"query": {
"type": "percolator"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
此测试过滤器查询有效
{
"query": {
"match": {
"message": "blah"
}
}
}
Run Code Online (Sandbox Code Playgroud)
此查询不起作用
{
"query": {
"simple_query_string": {
"query": "bl*"
}
}
}
Run Code Online (Sandbox Code Playgroud)
结果:
{"took":15,"timed_out":false,"_shards":{"total":5,"successful":5,"skipped":0,"failed":0},"hits":{"total":{"value":1,"relation":"eq"},"max_score":0.13076457,"hits":[{"_index":"my-index","_type":"_doc","_id":"1","_score":0.13076457,"_source":{"query":{"match":{"message":"blah"}}},"fields":{"_percolator_document_slot":[0]}}]}}
Run Code Online (Sandbox Code Playgroud)
为什么此simple_query_string查询与文档不匹配?
我正在使用elasticsearch的percolate功能.它运作良好 - 我得到匹配的percolate-ids返回一个新文档,并可以构建基本上反向搜索.到目前为止一切都很棒.
问题出在这里:我希望得到一个分数,表示给定文档与过滤器查询的匹配程度(正常查询给出的分数).要做到这一点,我添加了track_scores,但没有运气.
我在文档中找到了这个track_scores:
...分数基于查询并表示查询如何与percolate查询的元数据匹配,而不是如何将渗透的文档与查询匹配...
我想要/甚至需要什么?
这里有一个展示问题的样本(取自elasticsearch.org).1.0无论输入文档如何,在此处,percolate-response返回的分数始终为:
//Index the percolator
curl -XPUT 'localhost:9200/my-index/.percolator/1' -d '{
"query" : {
"match" : {
"message" : "bonsai tree"
}
}
}'
Run Code Online (Sandbox Code Playgroud)
渗透第一份文件:
curl -XGET 'localhost:9200/my-index/message/_percolate' -d '{
"doc" : {
"message" : "A new bonsai tree in the office"
},
"track_scores" : "true"
}'
//...returns
{"took": 1, "_shards": {
"total": 5,
"successful": 5,
"failed": 0
}, "total": 1, "matches": [
{ …Run Code Online (Sandbox Code Playgroud) 我正在尝试查询ElasticSearch以查找当前存储在系统上的所有过滤器查询.我的第一个想法是使用类型过滤器进行match_all但是从我的测试中,如果我执行match_all查询,它们似乎不会被返回.我没有为我的生活能够找到正确的方式来查询它们或任何文档,所以任何帮助都非常感谢.
此外,还有关于如何处理存储的过滤器查询与其他类型不同的任何其他信息.
我正在尝试使用Perl的Elasticsearch Percolator,我找到了这个很酷的模块.
据我所知,它们只是读取方法,因此只能读取查询索引并查看查询是否已存在,计算匹配的查询等.
除非我遗漏了某些内容,否则无法通过Percolator接口添加查询,因此我所做的是使用普通方法创建针对.percolator索引的文档,如下所示:
my $e = Search::Elasticsearch->new( nodes => 'localhost:9200' );
$e->create(
index => 'my_index',
type => '.percolator',
id => $max_idx,
body => {
query => {
match => {
...whatever the query is....
},
},
},
);
Run Code Online (Sandbox Code Playgroud)
这是通过perl模块向percolator索引添加查询的最佳方法吗?
谢谢!
我试图根据几个因素向用户提出建议:
•建议必须仅是来自同一所大学的学生 •建议必须至少匹配一个其他领域
我以为我有,但问题是这个查询将返回来自同一所学校的所有学生,而不管其他一切:
PUT /user/.percolator/4
{
"query": {
"bool": {
"must": [
{ "match": { "college":{
"query" : "Oakland University",
"type" : "phrase"
}}}
],
"should": [
{ "match": { "hashtag": "#chipotle" }},
{ "match": { "hashtag": "#running"}},
{ "match": { "college_course": "ART-160" }}
]
}
}
}
POST /user/stuff/_percolate/
{
"doc":{
"college":"Oakland University",
"college_course": "WRT BIO MTH-400"
}
}
Run Code Online (Sandbox Code Playgroud) 我正在为我的查询编制索引,如下所示:
client.Index(new PercolatedQuery
{
Id = "std_query",
Query = new QueryContainer(new MatchQuery
{
Field = Infer.Field<LogEntryModel>(entry => entry.Message),
Query = "just a text"
})
}, d => d.Index(EsIndex));
client.Refresh(EsIndex);
Run Code Online (Sandbox Code Playgroud)
现在,如何使用ES的过滤器功能将传入的文档与此查询进行匹配?说这个领域缺乏NEST文件将是一个巨大的轻描淡写.我尝试使用client.Percolatecall,但它现在已被弃用,他们建议使用搜索api,但不要告诉如何使用percolator ...
我正在使用ES v5和相同版本的NEST lib.
我有一个索引:产品
curl -XPUT "http://localhost:9200/products/product/1" -d'
{
"title": "Iphone 6",
"category_id": 4,
"price": 7788,
"owner_id": 21
}'
Run Code Online (Sandbox Code Playgroud)
如何为 3 个字段创建渗透索引:title、category_id、price?
Percolate Query这里我只找到了如何处理 1 个字段。
我们正在尝试设置和使用渗透,但我们并没有像预期的那样得到结果.
首先,我注册了几个问题:
curl -XPUT 'localhost:9200/index-234234/.percolator/query1' -d '{
"query" : {
"range" : {
"price" : { "gte": 100 }
}
}
}'
curl -XPUT 'localhost:9200/index-234234/.percolator/query2' -d '{
"query" : {
"range" : {
"price" : { "gte": 200 }
}
}
}'
Run Code Online (Sandbox Code Playgroud)
然后,当我尝试将它与150匹配时,理想情况下只匹配query1,而不是匹配两个查询:
curl -XGET 'localhost:9200/index-234234/message/_percolate' -d '{
"doc" : {
"price" : 150
}
}'
{"took":4,"_shards":{"total":5,"successful":5,"failed":0},"total":2,"matches":[{"_index":"index-234234","_id":"query1"},{"_index":"index-234234","_id":"query2"}]}
Run Code Online (Sandbox Code Playgroud)
关于为什么会发生这种情况的任何指示都将非常感激.
我想将我的许多文档扔给很多过滤器查询(我的查询计数是 6 位数字)。我已经找到了如何一次对多个文档进行多重渗透,但还没有找到如何一次批量添加多个查询。
根据文档,我可以使用以下方法在过滤器中注册查询:
curl -XPUT 'localhost:9200/my-index/.percolator/1' -d '{
"query" : {
"match" : {
"message" : "bonsai tree"
}
}
}'
Run Code Online (Sandbox Code Playgroud)
我可以一举添加其中的许多吗?