我如何使用C#为此创建索引

时间:2019-05-03 20:49:07

标签: c# elasticsearch nest

我是Nest的新手,我有一个可以在curl中运行的索引创建脚本。我想使用next在c#中创建它。 我真的很感谢您的帮助。 我看过木板,但我仍然感到困惑。

这是我的索引:

curl -XPUT http://localhost:9200/knowledgebaseproduct1 -H'Content- 
Type: application/json' -d '{
    "settings": {
        "number_of_shards": 1,
        "number_of_replicas": 0,
        "max_result_window" : "3000",
        "analysis": {
            "char_filter": {
                "removewhitespaces": {
                    "type": "pattern_replace",
                    "pattern": "\\s+",
                    "replacement": ""
                }
            },
            "filter": {
                "autocomplete_filter": {
                    "type": "edge_ngram",
                    "min_gram": 3,
                    "max_gram": 30
                },
                "removesymbols": {
                    "type": "pattern_replace",
                    "pattern": "[^A-Za-z0-9]",
                    "replacement": ""
                }
            },
            "analyzer": {
                "autocomplete": {
                    "type": "custom",
                    "tokenizer": "standard",
                    "filter": [
                        "lowercase",
                        "autocomplete_filter"
                    ]
                },
                "keyvalue": {
                    "type": "custom",
                    "tokenizer": "keyword",
                    "filter": [
                        "lowercase",
                        "asciifolding",
                        "removesymbols"
                    ],
                    "char_filter": [
                        "removewhitespaces"
                    ]
                },
                "basic": {
                    "type": "custom",
                    "tokenizer": "standard",
                    "filter": [
                        "lowercase"
                    ]
                }
            }
        }
    },
    "mappings": {
        "doc": {
            "dynamic": "strict",
            "properties": {
                "CompliFolderCompliFolderIdCriteria":{
                    "type": "long"
                },
                "CompliFolderCompanyIdCriteria": {
                    "type": "long"
                },
                "CompliFolderPhysicalStateLkpIdCriteria": {
                    "type": "long"
                },
                "CompliFolderStatusLkpIdCriteria":{
                    "type": "long"
                },
                "ObtainmentActionsNoticeNumberCriteria":{
                    "type": "text",
                    "fields": {
                        "autocompletefield": {
                            "type": "text",
                            "analyzer": "autocomplete",
                            "search_analyzer": "standard"
                        },
                        "keyvaluefield": {
                            "type": "text",
                            "analyzer": "keyvalue"
                        },
                        "basicfield": {
                            "type": "text",
                            "analyzer": "basic"
                        }
                    }
                },
                "ObtainmentWorkItemContainsProductCriteria":{
                    "type": "long"
                },
                "CompliFolderFolderNameCriteria": {
                    "type": "text",
                    "fields": {
                        "autocompletefield": {
                            "type": "text",
                            "analyzer": "autocomplete",
                            "search_analyzer": "standard"
                        },
                        "keyvaluefield": {
                            "type": "text",
                            "analyzer": "keyvalue"
                        },
                        "basicfield": {
                            "type": "text",
                            "analyzer": "basic"
                        }
                    }
                },
                "NameNumberNameOrNumberCriteria": {
                    "type": "text",
                    "fields": {
                        "autocompletefield": {
                            "type": "text",
                            "analyzer": "autocomplete",
                            "search_analyzer": "standard"
                        },
                        "keyvaluefield": {
                            "type": "text",
                            "analyzer": "keyvalue"
                        },
                        "basicfield": {
                            "type": "text",
                            "analyzer": "basic"
                        }
                    }
                },
                "NameNumberAliasCriteria": {
                    "type": "text",
                    "fields": {
                        "autocompletefield": {
                            "type": "text",
                            "analyzer": "autocomplete",
                            "search_analyzer": "standard"
                        },
                        "keyvaluefield": {
                            "type": "text",
                            "analyzer": "keyvalue"
                        },
                        "basicfield": {
                            "type": "text",
                            "analyzer": "basic"
                        }
                    }
                },
                "CompanyNameCriteria": {
                    "type": "text",
                    "fields": {
                        "autocompletefield": {
                            "type": "text",
                            "analyzer": "autocomplete",
                            "search_analyzer": "standard"
                        },
                        "keyvaluefield": {
                            "type": "text",
                            "analyzer": "keyvalue"
                        },
                        "basicfield": {
                            "type": "text",
                            "analyzer": "basic"
                        }
                    }
                },
                "CompanyAliasNameCriteria": {
                    "type": "text",
                    "fields": {
                        "autocompletefield": {
                            "type": "text",
                            "analyzer": "autocomplete",
                            "search_analyzer": "standard"
                        },
                        "keyvaluefield": {
                            "type": "text",
                            "analyzer": "keyvalue"
                        },
                        "basicfield": {
                            "type": "text",
                            "analyzer": "basic"
                        }
                    }
                }
            }
        }
    }
}'
sleep 5

0 个答案:

没有答案