学習ElasticSearch:ドキュメントを変更して再検索への追加および削除

  • ここでは一例として、インデックスデータベースのインデックスであり、まだ完全なJSONにデータを送信するために郵便配達を使用しています
    ここに画像を挿入説明

1、によって

ここに画像を挿入説明

  • 図1は、同じ一般的な_idと_idドキュメント、以下のないID、IDを指し
{
	"id":1,
	"title":"我是一个标题1",
	"content":"我是内容1"
}
  • その結果、成功を得ます
{
    "_index": "index",
    "_type": "1",
    "_id": "AW6dhLRtj92VZTE9RyoB",
    "_version": 1,
    "result": "created",
    "_shards": {
        "total": 2,
        "successful": 1,
        "failed": 0
    },
    "created": true
}

ここに画像を挿入説明

2、削除

ここに画像を挿入説明

  • リターンJSON
{
    "found": true,
    "_index": "index",
    "_type": "1",
    "_id": "AW6dhLRtj92VZTE9RyoB",
    "_version": 2,
    "result": "deleted",
    "_shards": {
        "total": 2,
        "successful": 1,
        "failed": 0
    }
}
  • ここで_idの後ろの数字は、

3、変更

  • 削除と追加し、あなたが直接操作を加えることができる場所、それが削除と追加されます:ここでの原則はあります
  • 変更する前に
    ここに画像を挿入説明
    ここに画像を挿入説明
  • リターンJSON
{
    "_index": "index",
    "_type": "hello",
    "_id": "1",
    "_version": 2,
    "result": "updated",
    "_shards": {
        "total": 2,
        "successful": 1,
        "failed": 0
    },
    "created": false
}
  • ビューデータ
    ここに画像を挿入説明

クエリIDに応じて4、

ここに画像を挿入説明

  • 要求は、クエリに到達するために変更され
  • JSONデータを返します
{
	"_index": "index",
	"_type": "hello",
	"_id": "1",
	"_version": 2,
	"found": true,
	"_source": {
		"id": 1,
		"title": "修改之后的文档",
		"content": "修改之后的内容"
	}
}

キーワードクエリによると5、

  • ここではポスト要求があります
    ここに画像を挿入説明
{
	"query":{
		"term":{
			"title":"修"
		}
	}
}
  • そして、で、クエリ用語キーワードです。、クエリは中国語の文字のみを入力することができますどこに
  • リターンJSON
{
	"took": 127,
	"timed_out": false,
	"_shards": {
		"total": 5,
		"successful": 5,
		"skipped": 0,
		"failed": 0
	},
	"hits": {
		"total": 2,
		"max_score": 0.28582606,
		"hits": [
			{
				"_index": "index",
				"_type": "hello",
				"_id": "1",
				"_score": 0.28582606,
				"_source": {
					"id": 1,
					"title": "修改之后的文档",
					"content": "修改之后的内容"
				}
			},
			{
				"_index": "index",
				"_type": "hello",
				"_id": "3",
				"_score": 0.25811607,
				"_source": {
					"id": 1,
					"title": "修改之后的文档as12d",
					"content": "修改之后的内12容"
				}
			}
		]
	}
}

6、のqueryString問い合わせ

  • この言葉を使用すると、クエリ上記の単語が同じであると、なります。
    ここに画像を挿入説明
  • 返されるJSON
{
	"took": 125,
	"timed_out": false,
	"_shards": {
		"total": 5,
		"successful": 5,
		"skipped": 0,
		"failed": 0
	},
	"hits": {
		"total": 2,
		"max_score": 0.5716521,
		"hits": [
			{
				"_index": "index",
				"_type": "hello",
				"_id": "1",
				"_score": 0.5716521,
				"_source": {
					"id": 1,
					"title": "修改之后的文档",
					"content": "修改之后的内容"
				}
			},
			{
				"_index": "index",
				"_type": "hello",
				"_id": "3",
				"_score": 0.51623213,
				"_source": {
					"id": 1,
					"title": "修改之后的文档as12d",
					"content": "修改之后的内12容"
				}
			}
		]
	}
}

7、延長

  • ビューのトークナイザでセグメンテーション効果
  • http://127.0.0.1:9200/_analyze?analyzer=standard&text=を入力します。
  • 英語や中国語でのテキストの後ろにライジング

英語のサポート

{
    "tokens": [
        {
            "token": "i",
            "start_offset": 0,
            "end_offset": 1,
            "type": "<ALPHANUM>",
            "position": 0
        },
        {
            "token": "am",
            "start_offset": 2,
            "end_offset": 4,
            "type": "<ALPHANUM>",
            "position": 1
        },
        {
            "token": "a",
            "start_offset": 5,
            "end_offset": 6,
            "type": "<ALPHANUM>",
            "position": 2
        },
        {
            "token": "hbu",
            "start_offset": 7,
            "end_offset": 10,
            "type": "<ALPHANUM>",
            "position": 3
        },
        {
            "token": "student",
            "start_offset": 11,
            "end_offset": 18,
            "type": "<ALPHANUM>",
            "position": 4
        }
    ]
}

中国のサポートについて

{
    "tokens": [
        {
            "token": "我",
            "start_offset": 0,
            "end_offset": 1,
            "type": "<IDEOGRAPHIC>",
            "position": 0
        },
        {
            "token": "是",
            "start_offset": 1,
            "end_offset": 2,
            "type": "<IDEOGRAPHIC>",
            "position": 1
        },
        {
            "token": "河",
            "start_offset": 2,
            "end_offset": 3,
            "type": "<IDEOGRAPHIC>",
            "position": 2
        },
        {
            "token": "北",
            "start_offset": 3,
            "end_offset": 4,
            "type": "<IDEOGRAPHIC>",
            "position": 3
        },
        {
            "token": "大",
            "start_offset": 4,
            "end_offset": 5,
            "type": "<IDEOGRAPHIC>",
            "position": 4
        },
        {
            "token": "学",
            "start_offset": 5,
            "end_offset": 6,
            "type": "<IDEOGRAPHIC>",
            "position": 5
        },
        {
            "token": "青",
            "start_offset": 6,
            "end_offset": 7,
            "type": "<IDEOGRAPHIC>",
            "position": 6
        },
        {
            "token": "年",
            "start_offset": 7,
            "end_offset": 8,
            "type": "<IDEOGRAPHIC>",
            "position": 7
        }
    ]
}
  • 実際には、これは中国のために非常に悪いので、実際の開発では、我々は、標準的なワードブレーカを使用していません
公開された134元の記事 ウォン称賛91 ビュー160 000 +

おすすめ

転載: blog.csdn.net/weixin_44588495/article/details/103228622