solr 利用cul或solr界面单值更新
本文主要是指利用solr界面或cul的更新solr的值。如果需要代码中单值更新请参考黎明露珠的博客链接:http://www.cnblogs.com/limingluzhu/p/5535314.html,我在文章的最末也给出了代码单值更新的示例。
在实际的研发过程中,为方便测试往往需要更改solr字段值,但是除了依赖程序的更新solr本身界面是否支持我们进行solr字段的值更新呢 ,答案是肯定支持的 。
详细方法请参考连接:http://yonik.com/solr/atomic-updates/
实际就是我们solr query的documents:
其示例documents 修改值方法如下 :
{
"ADDRESSID": "89fe3cffd70311e681c8fa163ea75434",
"MEMBERTYPE": {
"set": "1"
}
}
我这的 示例是json类型的,但是原理都一样的 。
这里的commit,可以理解为一个拼装起来的 get请求.当然你也可以用curl来直接请求。具体示例便是下文的curl请求。
关于具体语法问题原文如下:
Solr supports several modifiers that atomically update values of a document.
set– set or replace a particular value, or remove the value ifnullis specified as the new valueadd– adds an additional value to a listremove– removes a value (or a list of values) from a listremoveregex– removes from a list that match the given Java regular expressioninc– increments a numeric value by a specific amount (use a negative value to decrement)
具体示例原文如下:
Update Modifier Example
First, let’s add a document representing a book:
$ curl http://localhost:8983/solr/demo/update -d '
[
{"id" : "book1",
"title_t" : "Snow Crash", // text field
"copies_i" : 5,
"cat_ss" : "Science Fiction" // multi-valued string field
}
]'
Now we can update that document, adding the author field, incrementing the number of copies we have, and adding an additional category:
$ curl http://localhost:8983/solr/demo/update -d '
[
{"id" : "book1",
"author_s" : {"set":"Neal Stephenson"},
"copies_i" : {"inc":3},
"cat_ss" : {"add":"Cyberpunk"}
}
]'
Now if we retrieve the document using real-time get, we will see the updated fields:
$ curl http://localhost:8983/solr/demo/get?id=book1
{ "doc": { "id":"book1", "title_t":["Snow Crash"], "copies_i":8, "cat_ss":["Science Fiction", "Cyberpunk"], "author_s":"Neal Stephenson", "_version_":1408729977723027456}}And finally, remove “Cyberpunk” from the cat field:
$ curl http://localhost:8983/solr/demo/update -d '
[
{"id" : "book1",
"cat" : {"remove":"Cyberpunk"}
}
]'
Atomic Updates with SolrJ
Here is an example of how to do a partial update via Solr’s Java client, SolrJ:
// create the SolrJ client
HttpSolrClient client = new HttpSolrClient("http://localhost:8983/solr"); // create the document
SolrInputDocument sdoc = new SolrInputDocument();
sdoc.addField("id","book1");
Map<String,Object> fieldModifier = new HashMap<>(1);
fieldModifier.put("add","Cyberpunk");
sdoc.addField("cat", fieldModifier); // add the map as the field value client.add( sdoc ); // send it to the solr server client.close(); // shutdown client before we exit
CloudSolrClient server = new CloudSolrClient(ZkHost);
server.setParser(new XMLResponseParser());
SolrInputDocument doc = new SolrInputDocument();
Map<String, String> partialUpdate = new HashMap<String, String>();
partialUpdate.put("set", memberType);
doc.addField("ADDRESSID", addressId);//主键
doc.addField("MEMBERTYPE", partialUpdate);
doc.addField("LATESTUSETIME", DateUtils.getNow());
solr 利用cul或solr界面单值更新的更多相关文章
- Android开发——利用Cursor+CursorAdapter实现界面实时更新
好久没有更新博客了.不是没时间写,而是太懒.而且感觉有些东西没有时间总结,之之后再想写,就想不起来了.晚上新发现一点东西,所以就及时写下来. 最近利用业余时间在看Android的Download模块, ...
- Solr学习笔记---部署Solr到Tomcat上,可视化界面的介绍和使用,Solr的基本内容介绍,SolrJ的使用
学习Solr前需要有Lucene的基础 Lucene的一些简单用法:https://www.cnblogs.com/dddyyy/p/9842760.html 1.部署Solr到Tomcat(Wind ...
- 商城06——solr索引库搭建&solr搜索功能实现&图片显示问题解决
1. 课程计划 1.搜索工程的搭建 2.linux下solr服务的搭建 3.Solrj使用测试 4.把数据库中的数据导入索引库 5.搜索功能的实现 2. 搜索工程搭建 要实现搜索功能,需要搭建 ...
- solr课程学习系列-solr服务器配置(2)
本文是solr课程学习系列的第2个课程,对solr基础知识不是很了解的请查看solr课程学习系列-solr的概念与结构(1) 本文以windows的solr6服务器搭建为例. 一.solr的工作环境: ...
- Solr 01 - 什么是Solr + Solr安装包目录结构说明
目录 1 Solr概述 1.1 Solr是什么 1.2 Solr与Lucene的区别 2 Solr文件说明 2.1 Solr的目录结构 2.2 其他常用概念说明 2.3 创建基础文件目录 2.4 so ...
- Solr系列六:solr搜索详解优化查询结果(分面搜索、搜索结果高亮、查询建议、折叠展开结果、结果分组、其他搜索特性介绍)
一.分面搜索 1. 什么是分面搜索? 分面搜索:在搜索结果的基础上进行按指定维度的统计,以展示搜索结果的另一面信息.类似于SQL语句的group by 分面搜索的示例: http://localhos ...
- Solr系列四:Solr(solrj 、索引API 、 结构化数据导入)
一.SolrJ介绍 1. SolrJ是什么? Solr提供的用于JAVA应用中访问solr服务API的客户端jar.在我们的应用中引入solrj: <dependency> <gro ...
- Solr系列三:solr索引详解(Schema介绍、字段定义详解、Schema API 介绍)
一.Schema介绍 1. Schema 是什么? Schema:模式,是集合/内核中字段的定义,让solr知道集合/内核包含哪些字段.字段的数据类型.字段该索引存储. 2. Schema 的定义方式 ...
- Solr系列一:Solr(Solr介绍、Solr应用架构、Solr安装使用)
一.前言 前面已经学习了Lucene的分词.索引详解.搜索详解的知识,已经知道开发一个搜索引擎的流程了.现在就会有这样的一个问题:如果其他的系统也需要使用开发的搜索引擎怎么办呢?这个时候就需要把开发的 ...
随机推荐
- android mvp设计模式
什么是MVP MVP,全称 Model-View-Presenter.要说MVP那就不得不说一说它的前辈——MVC(Model-View-Controller,模型-视图-控制器). View:对应于 ...
- 快使用阿里云的maven仓库
自从开源中国的maven仓库挂了之后就一直在用国外的仓库,慢得想要砸电脑的心都有了.如果你和我一样受够了国外maven仓库的龟速下载?快试试阿里云提供的maven仓库,从此不在浪费生命…… 仓库地址: ...
- 首次接触XAMPP,端口被占用困恼
本人运气比较好,首次安装XAMPP就碰到了各种问题啊!并且已经解决,以下是我问题的出处并且解决. 问题描述: apache无法打开,并且连带的出现了mySql无法打开.(即80端口冲突问题) 解决办法 ...
- 常用 Git 命令文档和命令
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAA3IAAAEVCAIAAAAq20B9AAAgAElEQVR4nOydd3wUxfvH93p6gQRCCF ...
- poj 1185(状压dp)
题目链接:http://poj.org/problem?id=1185 思路:状态压缩经典题目,dp[i][j][k]表示第i行状态为j,(i-1)行状态为k时最多可以放置的士兵个数,于是我们可以得到 ...
- JavaScript------日期和时间戳的相互转换
var date = new Date(); 日期转时间戳 Number(date)或者date.getTime(); //只是转换成了纯数字的时间戳,例如:1498144203861需要转换才能使用 ...
- java必备——经典的Hibernate
在编程开发中,我们有非常多框架,他们有些非常方便,也非常有用,今天我们一起来认识一个java经典的框架Hibernate,Hibernate英文名称为"冬眠".这是个非常有意思的技 ...
- 网络虚拟化之FlowVisor:网络虚拟层(下)
在前面两篇文章:网络虚拟化之FlowVisor:网络虚拟层(上)和网络虚拟化之FlowVisor:网络虚拟层(中)中分别介绍了FLowVisor的特性和实现,三连载的最后一篇介绍虚拟网络的隔离机制. ...
- 修改yum源为阿里云的
将Centos的yum源更换为国内的阿里云源 author:headsen chen date:2018-04-28 13:33:41 1.备份 mv /etc/yum.repos.d/CentO ...
- POJ 2773 Happy 2006(容斥原理+二分)
Happy 2006 Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 10827 Accepted: 3764 Descr ...