首页 文章 精选 留言 我的

精选列表

搜索[实时查询],共10000篇文章
优秀的个人博客,低调大师

ES设置查询的相似度算法

similarity Elasticsearch allows you to configure a scoring algorithm orsimilarityper field. Thesimilaritysetting provides a simple way of choosing a similarity algorithm other than the defaultBM25, such asTF/IDF. Similarities are mostly useful fortextfields, but can also apply to other field types. Custom similarities can be configured by tuning the parameters of the built-in similarities. For more details about this expert options, see thesimilarity module. The only similarities which can be used out of the box, without any further configuration are: BM25 The Okapi BM25 algorithm. The algorithm used by default in Elasticsearch and Lucene. See Pluggable Similarity Algorithmsfor more information. classic The TF/IDF algorithm which used to be the default in Elasticsearch and Lucene. See Lucene’s Practical Scoring Functionfor more information. boolean A simple boolean similarity, which is used when full-text ranking is not needed and the score should only be based on whether the query terms match or not. Boolean similarity gives terms a score equal to their query boost. Thesimilaritycan be set on the field level when a field is first created, as follows: PUT my_index { "mappings": { "my_type": { "properties": { "default_field": { "type": "text" }, "classic_field": { "type": "text", "similarity": "classic" }, "boolean_sim_field": { "type": "text", "similarity": "boolean" } } } } } COPY AS CURL VIEW IN CONSOLE Thedefault_fielduses theBM25similarity. Theclassic_fielduses theclassicsimilarity (ie TF/IDF). Theboolean_sim_fielduses thebooleansimilarity. Default and Base Similarities By default, Elasticsearch will use whatever similarity is configured asdefault. However, the similarity functionsqueryNorm()andcoord()are not per-field. Consequently, for expert users wanting to change the implementation used for these two methods, while not changing thedefault, it is possible to configure a similarity with the namebase. This similarity will then be used for the two methods. You can change the default similarity for all fields in an index when it iscreated: PUT /my_index { "settings": { "index": { "similarity": { "default": { "type": "classic" } } } } } If you want to change the default similarity after creating the index you mustcloseyour index, send the follwing request andopenit again afterwards: PUT /my_index/_settings { "settings": { "index": { "similarity": { "default": { "type": "classic" } } } } } from:https://www.elastic.co/guide/en/elasticsearch/reference/5.4/index-modules-similarity.html 本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/bonelee/p/7451929.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

elasticSearch空间坐标的设置和查询

原文网址:http://blog.csdn.net/yangwenbo214/article/details/54411004 一、数据准备 为了方便起见,我模拟臆造了json格式的数据 {"timestamp":"2017-01-13T13:13:32.2516955+08:00","deviceId":"myFirstDevice","windSpeed":17,"haze":284,"city":"Beijing","lat":33.9402,"lon":116.40739} 1 模拟数据我用的是c#,大概如下: static void SendingRandomMessages() { //var eventHubClient = EventHubClient.CreateFromConnectionString(connectionString, eventHubName); int len = 4; string[] citys = { "Beijing", "Shangjhai", "Guangzhou", "Shenzhen" }; int[] avgWindSpeed = { 10, 16, 5, 7 }; int[] avgWindSpeed1 = { 10, 16, 5, 7 }; int[] avgHaze1 = { 200, 100, 50, 49 }; int[] avgHaze = { 200, 100, 50, 49 }; double[] latitude = { 39.3402, 31.23042, 23.13369, 22.54310 }; double[] longitude = { 116.40739, 121.47370, 113.28880, 114.057860 }; Random rand = new Random(); while (true) { try { for (int i = 0; i < len; i++) { avgWindSpeed[i] = avgWindSpeed1[i] + rand.Next(1, 11); avgHaze[i] = avgHaze1[i] + rand.Next(10, 100); var telemetryDataPoint = new { timestamp = DateTime.Now, deviceId = "myFirstDevice", windSpeed = avgWindSpeed[i], haze = avgHaze[i], city = citys[i], lat = latitude[i], lon = longitude[i] }; var message = JsonConvert.SerializeObject(telemetryDataPoint); //eventHubClient.Send(new EventData(Encoding.UTF8.GetBytes(message))); Console.WriteLine("{0} > Get message: {1}", "eventHubName", message); } } catch (Exception exception) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("{0} > Exception: {1}", DateTime.Now, exception.Message); Console.ResetColor(); } Thread.Sleep(200); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 此处我是作为消息发到一个eventhub中,你正确的做法可以将json写到文本文件中,再通过logstash读取即可 我的目的有两个: 获取数据中的lat、lon经纬度数据在kibana Map中进行绘图 获取数据中的timestamp作为我在kibana中的搜索时间,默认情况下是@timestamp 二、解决问题的整体思路 lat、lon本质上是float类型,此处需要设计一个mapping 日志内的时间,本质上应该是个字符串。我们得先卡出这个字段,然后用date match进行转换 三、解决实例 1. mapping的设计,我给出一个template { "template": "geo-*", "settings": { "index.refresh_interval": "5s" }, "mappings": { "_default_": { "_all": {"enabled": true, "omit_norms": true}, "dynamic_templates": [ { "message_field": { "match": "message", "match_mapping_type": "string", "mapping": { "type": "string", "index": "analyzed", "omit_norms": true } } }, { "string_fields": { "match": "*", "match_mapping_type": "string", "mapping": { "type": "string", "index": "analyzed", "omit_norms": true, "fields": { "raw": {"type": "string", "index": "not_analyzed", "ignore_above": 256} } } } } ], "properties": { "@version": { "type": "string", "index": "not_analyzed" }, "lonlat": { "type": "geo_point" } } } } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 大概解释如下: “template”: “geo-*”,所有geo开头的索引,都将会套用这个template配置 “lonlat”: { “type”: “geo_point” } 这个定义了lonlat为geo_point类型,为以后Map绘制奠定基础,这个是关键。 NOTE:这个lonlat名字不能取成特定的关键名字?,我取成location一直报错。 更加详细的介绍你可以查看官网文档 2. 给出logstash的配置文件 input { file { path => "/opt/logstash/1.log" start_position => "beginning" sincedb_path => "/dev/null" } } filter { json { source => "message" } mutate { add_field => [ "[lonlat]", "%{lon}" ] add_field => [ "[lonlat]", "%{lat}" ] } date{ match=>["timestamp","ISO8601"] timezone => "Asia/Shanghai" "target" => "logdate" } } output { stdout { codec => rubydebug } elasticsearch { hosts =>"wb-elk" index => "geo-%{+YYYY.MM.dd}" # template => "/opt/logstash/monster.json" # template_overwrite => true } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 大概解释一下: json {source => “message”}这个能将json数据格式分解出一个个字段 mutate 这个是向geo_point中加入经纬度数据 date {match=>}这个是将匹配json数据分解出来的timestamp,并以时间格式赋值给logdate output中注释掉的是template文件。我采用的是直接put template的方式,因此注释掉了。两个方法都可行 补充:经纬度信息格式确定和重命名: mutate { convert => { "lon" => "float" } convert => { "lat" => "float" } } mutate { rename => { "lon" => "[lonlat][lon]" "lat" => "[lonlat][lat]" } } 3.运行过程

优秀的个人博客,低调大师

mysql表碎片的查询自己回收

在MySQL中,我们经常会使用VARCHAR、TEXT、BLOB等可变长度的文本数据类型。不过,当我们使用这些数据类型之后,我们就不得不做一些额外的工作——MySQL数据表碎片整理。 每当MySQL从你的列表中删除了一行内容,该段空间就会被留空。而在一段时间内的大量删除操作,会使这种留空的空间变得比存储列表内容所使用的空间更大。 当MySQL对数据进行扫描时,它扫描的对象实际是列表的容量需求上限,也就是数据被写入的区域中处于峰值位置的部分。如果进行新的插入操作,MySQL将尝试利用这些留空的区域,但仍然无法将其彻底占用。 1.或者查看某个表所占空间,以及碎片大小。 select table_name,engine,table_rows,data_length+index_length length,DATA_FREE from information_schema.tables where TABLE_SCHEMA='test'; 或者 select table_name,engine,table_rows,data_length+index_length length,DATA_FREE from information_schema.tables wheredata_free !=0; +------------+--------+------------+--------+-----------+ | table_name | engine | table_rows | length | DATA_FREE | +------------+--------+------------+--------+-----------+ | curs | InnoDB | 0 | 16384 | 0 | | t | InnoDB | 10 | 32768 | 0 | | t1 | InnoDB | 9 | 32768 | 0 | | tn | InnoDB | 7 | 16384 | 0 | +------------+--------+------------+--------+-----------+table_name 表的名称engine :表的存储引擎table_rows 表里存在的行数data_length 表的大小(表数据+索引大小)DATA_FREE :表碎片的大小 以上单位都是byte字节 整理碎片: 整理碎片过程会锁边,尽量放在业务低峰期做操作1、myisam存储引擎回收碎片optimize table aaa_safe,aaa_user,t_platform_user,t_user; 2、innodb存储引擎回收碎片alter table t engine=innodb;:1.MySQL官方建议不要经常(每小时或每天)进行碎片整理,一般根据实际情况,只需要每周或者每月整理一次即可。2.OPTIMIZE TABLE运行过程中,MySQL会锁定表。4.默认情况下,直接对InnoDB引擎的数据表使用OPTIMIZE TABLE或 脚本回收innodb表碎片 #!/bin/bash DB=test USER=root PASSWD=root123 HOST=192.168.2.202 MYSQL_BIN=/usr/local/mysql/bin D_ENGINE=InnoDB $MYSQL_BIN/mysql -h$HOST -u$USER -p$PASSWD $DB -e "select TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA='"$DB"' "';" | grep -v "TABLE_NAME" >tables.txt for t_name in `cat tables.txt` do echo "Starting table $t_name......" sleep 1 $MYSQL_BIN/mysql -h$HOST -u$USER -p$PASSWD $DB -e "alter table $t_name engine='"$D_ENGINE"'" if [ $? -eq 0 ] then echo "shrinktable $t_name ended." >>con_table.log sleep 1 else echo "shrinkfailed!" >> con_table.log fi done

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册