简体   繁体   English

在Elasticsearch中搜索通过摄取附件索引的文档

[英]Searching documents indexed via ingest-attachment in elasticsearch

Searching documents indexed via ingest-attachment in elastic search on basis of attributes. 在基于属性的弹性搜索中搜索通过摄取附件索引的文档。

i'm new to elastic search and wanted to index files with some of the attributes like Author, Title, Subject, Category, Community etc. 我是弹性搜索的新手,并希望使用某些属性(例如作者,标题,主题,类别,社区等)对文件建立索引。

How far i reached :- 我走了多远:-

i was able to create a attachment pipeline and was able to ingest the different docs in the elastic with attributes. 我能够创建一个附件管道,并且能够使用属性来摄取弹性文档中的不同文档。 see below how i did:- 看看下面我是怎么做的:-

1) created pipeline by following request:- 1)通过以下请求创建管道:

{  
"description":"Extract attachment information",
"processors":[  
  {  
     "attachment":{  
        "field":"data"
     }
  }
]
}

2) upload an attachment via following code :- 2)通过以下代码上传附件:

{
"filename":"Presentations-Tips.ppt",
"Author":"Jaspreet",
"Category":"uploading ppt",
"Subject":"testing ppt",
"fileUrl":"",
"attributes": 
{"attr11":"attr11value","attr22":"attr22value","attr33":"attr33value"},
"data": "here_base64_string_of_file"
}

3) then able to search freely on the all the above attributes and on file content as well:- 3)然后可以自由搜索上述所有属性以及文件内容:-

 {
 "query":{
 "query_string":{
    "query":"*test*"
 }
 }
 }

Now what I wanted is :- Wanted to narrow down the searches through some filters like :- 现在我想要的是:-想通过一些过滤器来缩小搜索范围:-

  1. wanted to search on basis like search on specific parameters like search all those whose author must "Rohan" 想要像在特定参数上一样进行搜索,例如搜索所有作者必须“ Rohan”的人
  2. then search all whose author must be "Rohan" and category must be "Education" 然后搜索所有作者必须为“ Rohan”且类别必须为“ Education”的人
  3. then search all whose author has letters like "han" and categories has letters "Tech" 然后搜索所有作者的字母如“ han”和类别的字母“ Tech”的人
  4. search all whose author is "Rohan" and can search full text search on all fields which can have "progress" in any field, means first narrow down search for author and then full text search on those resultset fields. 搜索所有作者为“ Rohan”的人,并且可以在所有字段中可以有“进步”的所有字段中搜索全文搜索,这意味着首先要缩小搜索范围,然后再对那些结果集字段进行全文搜索。

Please help me with proper query syntax and call url like for above full text search I used 'GET /my_index/_search' 请使用正确的查询语法为我提供帮助,并致电url,就像上面的全文搜索一样,我使用的是'GET / my_index / _search'

After spending some time finally got the answer:- 花了一些时间终于得到了答案:-

curl -X POST \
  http://localhost:9200/my_index/_search \
  -H 'Content-Type: application/json' \
  -d '{
    "query": {
        "bool": {
            "must": [
                {
                    "query_string": {
                        "query": "progress"
                    }
                },
                {
                    "wildcard": {
                        "Author": "Rohan"
                    }
                },
                {
                    "wildcard": {
                        "Title": "q*"
                    }
                }
            ]
        }
    }
}'

now in above you can remove or add any object in must array as per your need. 现在,您可以根据需要在must数组中删除或添加任何对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM