gpt4 book ai didi

html - Elasticsearch原始HTML文档搜索

转载 作者:行者123 更新时间:2023-12-03 00:06:07 24 4
gpt4 key购买 nike

我将网站的原始html存储在ElasticSearch中,示例字段称为“html_content”:

"\ufeff<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\t<head>\t  \t<base href=\"http://forum.pl\">\t  \t\t  \t<!-- Google Webmaster Tools -->\t\t\t\t<meta name=\"google-site-verification\" content=\"F6oatYg_CzKAKO7hA3Sy11S10eS0_ZYC1yGaoMbKYTU\" />\t\t\t  \t    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\t    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=EmulateIE7\" />\t    \t    \t    \t   \t<title>Dolnośląska Fundacja Rozowju Regionalnego - Forum.pl</title>\t    \t    <link href=\"/public/css/style.css\" rel=\"stylesheet\" type=\"text/css\">\t\t<link rel=\"stylesheet\" href=\"/public/css/menu.css\" type=\"text/css\" />\t\t<!--[if IE 6]>\t\t<link href=\"/public/css/clean_ie6.css\" rel=\"stylesheet\" type=\"text/css\" />\t\t<![endif]-->\t\t<!--[if IE 7]>\t\t<link href=\"/public/css/clean_ie.css\" rel=\"stylesheet\" type=\"text/css\"    

现在,我想执行搜索并查找具有以下内容的所有文档:
 rel="stylesheet" type="text/css    

在html_content字段中。

我应该如何创建索引(应该使用什么映射和分析器)?
我应该如何创建搜索查询?

我从文档和Google尝试了很多东西,但找不到答案。

最佳答案

对于我使用的分析器:

{
"settings": {
"analysis": {
"analyzer": {
"testowy": {
"type": "custom",
"tokenizer": "standard",
"filter": "lowercase"
}
}
}}}

对于搜索,例如:
{
"query": {
"match_phrase" : {
"html_content" : {
"query" : "rel=\"stylesheet\" type=\"text/css"
}
}
}}

或查找具有2个匹配项的文档:
    {
"query": {
"bool": {
"must": [
{"match_phrase": {"html_content": "rel=\"stylesheet\" type=\"text/css"}},
{"match_phrase": {"html_content": "<meta name=\"distribution\""}}
]
}
}
}

我还是不知道为什么 "rel=\"stylesheet\" type=\"text/css"不等于
"rel=\"stylesheet\" type=\"text/cs"

关于html - Elasticsearch原始HTML文档搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44684712/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com