1.4.7 Schema API
Schema API
Schema API允许使用REST API每个集合(collection)(或者单机solr的核(core)).包含了定义字段类型,字段,动态字段,复制字段等.在solr4.2或4.3中,仅仅允许Get(只读)访问,在solr4.4上,新的字段和复制字段可以直接加入到schema中.未来,solr版本将会扩展这个功能,以允许更多的schema元素可以被更新.
使用API启动schema修改,请参考Managed Schema Definition in SolrConfig.
对于所有的调用,这个API支持两种模式:JSON和XML.当请求了完整的Schema之后,会有另外一种仿照schema.xml文件本身的XML模式.
API的基本地址:http://<host>:<port>/<context-path>,其中<context-path>通常都是solr.
1.API入口点
2.检索Schema信息
2.1检索完成的schema
2.2列出字段
2.3列出指定的字段
2.4列出动态字段
2.5列出指定的动态字段规则
2.6列出字段类型
2.7列出指定的字段类型
2.8列出复制字段
2.9显示schema名字
2.10显示schema版本
2.11列出唯一主键Unique
2.12显示全局Similarity
2.13获取默认的查询操作
3.修改schema
3.1创建新的schema字段
3.2创建一个新的schema字段
3.3 直接创建新的复制字段
4.相关主题
1.API入口点
/collection/schema:检索整个schema.
/collection/schema/fields:检索所有定义的字段的信息,或者使用copyField直接常见新的字段.
/collection/schema/fields/name:检索一个字段的信息,或者使用copyField命令直接创建一个新的命名的字段.
/collection/schema/dynamicfields:检索动态字段规则信息
/collection/schema/dynamicfields/name:检索一个命名的动态字段信息
/collection/schema/fieldtypes:检索字段类型
/collection/schema/fieldtypes/name:检索一个命名的字段类型
/collection/schema/copyfields:检索复制字段或者创建新的复制字段
/collection/schema/name:取回schema的名称
/collection/schema/version:取回schema的版本
/collection/schema/uniquekey:取回定义的uniquekey
/collection/schema/similarity:取回全局的similarity
/collection/schema/solrqueryparser/defaultoperator:检索默认操作
2.检索Schema信息
2.1检索完成的schema
GET /collection/schema
输入
路径参数
collection:collection或者core的名称
查询参数
查询参数可以放在API请求的问号"?"之后.
| Key | Type | Required | Default | Description |
| wt | string | No | json |
定义响应格式,选项可以是json,xml或者是schema.xml. 如果没有指定,JSON将会被默认返回 |
输出
输出内容将包含所有的字段,字段类型,动态字段,复制字段.同样也包含schema名称和版本号.
例子
输入
采用json方式取回全部的schema
curl http://localhost:8983/solr/collection1/schema?wt=json
采用xml方式取回全部的schema
curl http://localhost:8983/solr/collection1/schema?wt=xml
采用 "schema.xml"方式取回全部的schema
curl http://localhost:8983/solr/collection1/schema?wt=schema.xml
输出
JSON例子:
{
"responseHeader":{
"status":0,
"QTime":5},
"schema":{
"name":"example",
"version":1.5,
"uniqueKey":"id",
"fieldTypes":[{
"name":"alphaOnlySort",
"class":"solr.TextField",
"sortMissingLast":true,
"omitNorms":true,
"analyzer":{
"tokenizer":{
"class":"solr.KeywordTokenizerFactory"},
"filters":[{
"class":"solr.LowerCaseFilterFactory"},
{
"class":"solr.TrimFilterFactory"},
{
"class":"solr.PatternReplaceFilterFactory",
"replace":"all",
"replacement":"",
"pattern":"([^a-z])"}]}},
...
"fields":[{
"name":"_version_",
"type":"long",
"indexed":true,
"stored":true},
{
"name":"author",
"type":"text_general",
"indexed":true,
"stored":true},
{
"name":"cat",
"type":"string",
"multiValued":true,
"indexed":true,
"stored":true},
...
"copyFields":[{
"source":"author",
"dest":"text"},
{
"source":"cat",
"dest":"text"},
{
"source":"content",
"dest":"text"},
...
{
"source":"author",
"dest":"author_s"}]}}
XML例子:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">5</int>
</lst>
<lst name="schema">
<str name="name">example</str>
<float name="version">1.5</float>
<str name="uniqueKey">id</str>
<arr name="fieldTypes">
<lst>
<str name="name">alphaOnlySort</str>
<str name="class">solr.TextField</str>
<bool name="sortMissingLast">true</bool>
<bool name="omitNorms">true</bool>
<lst name="analyzer">
<lst name="tokenizer">
<str name="class">solr.KeywordTokenizerFactory</str>
</lst>
<arr name="filters">
<lst>
<str name="class">solr.LowerCaseFilterFactory</str>
</lst>
<lst>
<str name="class">solr.TrimFilterFactory</str>
</lst>
<lst>
<str name="class">solr.PatternReplaceFilterFactory</str>
<str name="replace">all</str>
<str name="replacement" />
<str name="pattern">([^a-z])</str>
</lst>
</arr>
</lst>
</lst>
...
<lst>
<str name="source">author</str>
<str name="dest">author_s</str>
</lst>
</arr>
</lst>
</response>
schema.xml格式例子
<?xml version="1.0" encoding="UTF-8"?>
<schema name="example" version="1.5">
<uniqueKey>id</uniqueKey>
<types>
<fieldType name="alphaOnlySort" class="solr.TextField"
sortMissingLast="true" omitNorms="true">
<analyzer>
<tokenizer class="solr.KeywordTokenizerFactory" />
<filter class="solr.LowerCaseFilterFactory" />
<filter class="solr.TrimFilterFactory" />
<filter class="solr.PatternReplaceFilterFactory" replace="all"
replacement="" pattern="([^a-z])" />
</analyzer>
</fieldType>
...
<copyField source="url" dest="text" />
<copyField source="price" dest="price_c" />
<copyField source="author" dest="author_s" />
</schema>
2.2列出字段
GET /collection/schema/fields
输入
路径参数
collection:collection或者core的名称
查询参数
| Key | Type | Required | Default | Description |
| wt | string | No | json |
定义响应格式,选项可以是json,xml或者是schema.xml. 如果没有指定,JSON将会被默认返回 |
输出
取回所有字段的列表
curl http://localhost:8983/solr/collection1/schema/fields?wt=json
结果
{
"fields": [
{
"indexed": true,
"name": "_version_",
"stored": true,
"type": "long"
},
{
"indexed": true,
"name": "author",
"stored": true,
"type": "text_general"
},
{
"indexed": true,
"multiValued": true,
"name": "cat",
"stored": true,
"type": "string"
},
...
],
"responseHeader": {
"QTime": 1,
"status": 0
}
}
2.3列出指定的字段
GET /collection/schema/fields/fieldname
输入
路径参数:
collection:集合或核的名称
filedname:指定字段名称
查询参数:
查询参数可以加入到request请求问号?之后.
| Key | Type | Required | Default | Description |
| wt | string | No | json |
定义响应格式,选项可以是json,xml或者是schema.xml. 如果没有指定,JSON将会被默认返回 |
2.4列出动态字段
2.5列出指定的动态字段规则
2.6列出字段类型
2.7列出指定的字段类型
2.8列出复制字段
2.9显示schema名字
2.10显示schema版本
2.11列出唯一主键Unique
2.12显示全局Similarity
2.13获取默认的查询操作
3.修改schema
3.1创建新的schema字段
3.2创建一个新的schema字段
3.3 直接创建新的复制字段
4.相关主题
1.4.7 Schema API的更多相关文章
- Solr系列三:solr索引详解(Schema介绍、字段定义详解、Schema API 介绍)
一.Schema介绍 1. Schema 是什么? Schema:模式,是集合/内核中字段的定义,让solr知道集合/内核包含哪些字段.字段的数据类型.字段该索引存储. 2. Schema 的定义方式 ...
- 1.4 Documents,Fields和Schema设计--目录
1.4.1.Documents,Fields和Schema概述 1.4.2 solr字段类型 1.4.2 solr字段类型--(1.4.2.1)字段类型定义和字段类型属性 1.4.2 solr字段类型 ...
- Rest API
一.前言 在软件行业快速发展的今天,传统的软件授权已经不能足以满足一个IT类的公司的发展.虽然在大部分公司里,它还是现金池的直接源头.但是在可遇见的未来,受摩尔根理论的失效.物联网的发展等影响,应用的 ...
- GoldenGate 12.3 MA架构介绍系列(4)–Restful API介绍
OGG 12.3 MA中最大的变化就是使用了restful api,在前面介绍的各个服务模块,其实就是引用restful api开发而来,这些API同时也提供对外的集成接口,详细接口可参考: http ...
- Solr特性:Schemaless Mode(自动往Schema中添加field)
WiKi:https://cwiki.apache.org/confluence/display/solr/Schemaless+Mode 介绍: Schemaless Mode is a set o ...
- REST API 安全设计
REST API 安全设计 2017年04月27日 18:34:27 阅读数:1699 Rest API 的那些事儿 作者/ asterisk 在软件行业快速发展的今天,传统的软件授权已经不能足以 ...
- 【solr】schemaFactory配置相关schema.xml
schemaFactory配置相关schema.xml 关于schemaFactory的配置困扰我半天啦,下面来总结一下. 话说,好像是从5.0以后就已经没有schema.xml啦,这是由于Solr ...
- Tastypie 学习笔记
Tastypie是什么? 运行于Python环境中的 Django web服务器下的 Restful 风格API接口 (python 类库) 1.安装下面环境或者依赖包到python库(安装过程类似 ...
- Solr官方文档翻译-About & Getting Started
关于(About) 官方文档介绍了所有的Apache Solr实现的重要特性和功能.它是免费的,可以到http://lucene.apache.org/solr/下载. 为了更加的深入和广泛,设计成一 ...
随机推荐
- 何时使用hadoop fs、hadoop dfs与hdfs dfs命令
hadoop fs:使用面最广,可以操作任何文件系统. hadoop dfs与hdfs dfs:只能操作HDFS文件系统相关(包括与Local FS间的操作),前者已经Deprecated,一般使用后 ...
- 二、 C#调用存储过程
个人比较喜欢使用第二种传递参数的方法 1. 调用的方法 public DataTable ExceStoredProcedure (string strCom, SqlParameter[] comm ...
- Could not find a transformer to transform "SimpleDataType{type=org.mule.transport.NullPayload
mule esb报错 com.isoftstone.esb.transformer.Json2RequestBusinessObject.transformMessage(Json2RequestBu ...
- JSF 2 panelGrid example
In JSF , "h:panelGrid" tag is used to generate HTML table tags to place JSF components in ...
- web.xml filter 顺序
The order the container uses in building the chain of filters to be applied for a particular request ...
- M站 confirm 插件
/*弹出提示*/.pop-error{position:absolute; left:25%; top:50%; width:200px; FILTER: progid:DXImageTransfor ...
- 如何用C++语言编程(How to program in C++)
这几年在公司一直带徒弟,每次必教的内容就是C++.在我看来,C++已经有非常好的教材了(注1),实在没有必要从头教起.自学就可以了,可是结果总是不尽人意. 不想再重复一次"把C++当成一门新 ...
- CSS line-height 和 vertical-align 精解(上篇)
声明本文转自:http://hi.baidu.com/wolongxzg/item/a39ef8299c984283af48f5b0 line-height属性的具体定义列表如下: 语法: line- ...
- Json.Net学习笔记
http://www.cnblogs.com/xiaojinhe2/archive/2011/10/28/2227789.html Newtonsoft.Json(Json.Net)学习笔记 http ...
- C# —— IList, ArrayList与List的区别详解
共同点: IList, List , ArrayList 通俗一点来讲就是广义的数组,C#里面称之为集合.不同于一般的狭义的数组,它们可以存放任意类型的东西,在申明或者赋值的时候指定. 比如你写 ...