初识pyes(实现elasticsearch数据的插入)
来源:互联网 发布:淘宝客服如何打开分流 编辑:程序博客网 时间:2024/05/10 21:00
名词解释:
boost:
boost参数被用来增加一个子句的相对权重(当boost大于1时),或者减小相对权重(当boost介于0到1时),但是增加或者减小不是线性的。换言之,boost设为2并不会让最终的_score加倍。
相反,新的_score会在适用了boost后被归一化(Normalized)。每种查询都有自己的归一化算法(Normalization Algorithm)。但是能够说一个高的boost值会产生一个高的_score。
如果你在实现你自己的不基于TF/IDF的相关度分值模型并且你需要对提升过程拥有更多的控制,你可以使用function_score查询,它不通过归一化步骤对文档的boost进行操作。index:如果是no,则无法通过检索查询到该字段;如果设置为not_analyzed则会将整个字段存储为关键词,常用于汉字短语、邮箱等复杂的字符串;如果设置为analyzed则将会通过默认的standard分析器进行分析,详细的分析规则参考这里store:true 独立存储false(默认)不存储,从_source中解析
看代码
#!/usr/bin/env python# -*- coding: utf-8 -*-"""Created on 2017-11-20@author: Negen"""import pyes#创建ES连接,这是我的ip地址,个人本机上就用localhost,默认端口9200conn = pyes.ES(['10.139.32.155:9200'])#判断索引是否存在if conn.indices.exists_index("test-index"): print '该索引已存在'else: # 创建一个新的索引(即sql中的create database) conn.indices.create_index("test-index")#定义索引存储结构mapping相当于sql中的字段mapping = { u'parsedtext':{ 'boost':1.0, 'index':'analyzed', 'store':'yes', 'type':u'string', 'term_vector':'with_positions_offsets' }, u'name':{ 'boost':1.0, 'index':'analyzed', 'store':'yes', 'type':u'string', 'term_vector':'with_positions_offsets' }, u'titlte':{ 'boost': 1.0, 'index': 'analyzed', 'store': 'yes', 'type': u'string', 'term_vector': 'with_positions_offsets' }, u'position':{ 'store': 'yes', 'type': u'integer', }, u'uuid':{ 'boost': 1.0, 'index': 'analyzed', 'store': 'yes', 'type': u'string' }}#定义test-type 相当于sql 中的 create table test-typeconn.indices.put_mapping("test-type",{"properties":mapping},["test-index"])#继承test-type 相当于sql 中的 create table test-type2conn.indices.put_mapping("test-type2",{"_parent":{"type":"test-type"}},["test-index"])#插入数据 相当于sql中的insertconn.index({"name":"Joe Tester", "parsedtext":"Joe Testere nice guy", "uuid":"11111", "position":1}, "test-index", "test-type", 1)conn.index({"name":u"百 度 中 国"}, "test-index", "test-type")
阅读全文
1 0
- 初识pyes(实现elasticsearch数据的插入)
- pyes对elasticsearch的数据基本查询
- elasticsearch中数据的插入与查询
- ElasticSearch插入数据
- ElasticSearch插入数据优化
- elasticsearch插入数据
- ElasticSearch插入数据问题
- 大数据下的日志--ElasticSearch部分(一)--初识
- pyes Search 的sort用法
- (五)ElasticSearch插入数据
- Elasticsearch java api 插入数据
- 搜索引擎–elasticsearch python客户端pyes 建立索引和搜索
- 初识Elasticsearch
- Elasticsearch初识
- 初识ElasticSearch
- 初识ElasticSearch
- 初识Elasticsearch
- 使用Python往Elasticsearch插入数据
- 以程序员专业的角度告诉你,头条推荐机制具体是怎么样的
- 面试宝典读书笔记
- PLSQL连接oracle数据库
- rapidjson
- Visual Studio 2013/2015/2017快捷键(转)
- 初识pyes(实现elasticsearch数据的插入)
- MYsql数据类型
- AsyncLogger
- imx6q 板子ping win7主机 Ubuntu14.04主机
- hadoop HDFS存储原理
- Docker常用命令详解
- 图像直方图均衡化
- BinaryApplication
- 2个月搭建一个嵌入式开发平台,你觉得可以实现吗?