| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- """
- Elasticsearch 动态模板映射
- """
- from typing import Dict, Any
- def get_dynamic_templates() -> Dict[str, Any]:
- """
- 获取动态模板映射配置
- 参考:d:/project/work/ragflow_plugs/book/es_dynamic.md
-
- Returns:
- Dict[str, Any]: 动态模板映射配置
- """
- return {
- "dynamic_templates": [
- {
- "int": {
- "match": "*_int",
- "mapping": {
- "store": True,
- "type": "integer"
- }
- }
- },
- {
- "ulong": {
- "match": "*_ulong",
- "mapping": {
- "store": True,
- "type": "unsigned_long"
- }
- }
- },
- {
- "long": {
- "match": "*_long",
- "mapping": {
- "store": True,
- "type": "long"
- }
- }
- },
- {
- "short": {
- "match": "*_short",
- "mapping": {
- "store": True,
- "type": "short"
- }
- }
- },
- {
- "numeric": {
- "match": "*_flt",
- "mapping": {
- "store": True,
- "type": "float"
- }
- }
- },
- {
- "tks": {
- "match": "*_tks",
- "mapping": {
- "analyzer": "whitespace",
- "similarity": "scripted_sim",
- "store": True,
- "type": "text"
- }
- }
- },
- {
- "ltks": {
- "match": "*_ltks",
- "mapping": {
- "analyzer": "whitespace",
- "store": True,
- "type": "text"
- }
- }
- },
- {
- "kwd": {
- "match": "^(.*_(kwd|id|ids|uid|uids)|uid)$",
- "match_pattern": "regex",
- "mapping": {
- "similarity": "boolean",
- "store": True,
- "type": "keyword"
- }
- }
- },
- {
- "dt": {
- "match": "^.*(_dt|_time|_at)$",
- "match_pattern": "regex",
- "mapping": {
- "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||yyyy-MM-dd_HH:mm:ss",
- "store": True,
- "type": "date"
- }
- }
- },
- {
- "nested": {
- "match": "*_nst",
- "mapping": {
- "type": "nested"
- }
- }
- },
- {
- "object": {
- "match": "*_obj",
- "mapping": {
- "dynamic": True,
- "type": "object"
- }
- }
- },
- {
- "string": {
- "match": "^.*_(with_weight|list)$",
- "match_pattern": "regex",
- "mapping": {
- "index": False,
- "store": True,
- "type": "text"
- }
- }
- },
- {
- "rank_feature": {
- "match": "*_fea",
- "mapping": {
- "type": "rank_feature"
- }
- }
- },
- {
- "rank_features": {
- "match": "*_feas",
- "mapping": {
- "type": "rank_features"
- }
- }
- },
- {
- "dense_vector_512": {
- "match": "*_512_vec",
- "mapping": {
- "dims": 512,
- "index": True,
- "similarity": "cosine",
- "type": "dense_vector"
- }
- }
- },
- {
- "dense_vector_768": {
- "match": "*_768_vec",
- "mapping": {
- "dims": 768,
- "index": True,
- "similarity": "cosine",
- "type": "dense_vector"
- }
- }
- },
- {
- "dense_vector_1024": {
- "match": "*_1024_vec",
- "mapping": {
- "dims": 1024,
- "index": True,
- "similarity": "cosine",
- "type": "dense_vector"
- }
- }
- },
- {
- "dense_vector_1536": {
- "match": "*_1536_vec",
- "mapping": {
- "dims": 1536,
- "index": True,
- "similarity": "cosine",
- "type": "dense_vector"
- }
- }
- },
- {
- "binary": {
- "match": "*_bin",
- "mapping": {
- "type": "binary"
- }
- }
- }
- ],
- "date_detection": True
- }
|