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/下载. 为了更加的深入和广泛,设计成一 ...
随机推荐
- C++11lambda表达式
[C++11lambda表达式] mutable 修饰符,用于修改[]中以值传递的变量,无mutable修饰符的话则不行. 使用示例: #include <vector> #include ...
- printf函数重定向
printf函数底层会调用fputc函数 /*重定向c库函数printf到USART1*/ int fputc(int ch, FILE *f) { /*发送一个字节数据USART1 */ USART ...
- KMP应用http://acm.hdu.edu.cn/showproblem.php?pid=2594
riemann与marjorie拼接后riemannmarjorie前缀与后缀公共部分为 rie 长度为 3(即next[l] = next[14]的值,l为拼接后的长度)但:aaaa与aa拼接后aa ...
- HDU 5702 Solving Order (水题,排序)
题意:给定几种不同的颜色和它的权值,按它的权值排序. 析:排序. 代码如下: #include <cstdio> #include <string> #include < ...
- defaultAutoCommit
driver default The default auto-commit state of connections created by this pool. If not set then th ...
- SQL Server中行列转换
典型实例 一.行转列 1.建立表格 ifobject_id('tb')isnotnulldroptabletb go createtabletb(姓名varchar(10),课程varchar(10) ...
- 题外话(简识UML语言)
PS:“不积小流无以成为江河,不积跬步无以至千里”,学习也好,吃饭也罢,做任何事情都需要一步一个脚印,逐步积累过程,最后才会知识越来越丰富,吃的越饱… 在学习过程中用到了一些框图,用于绘画框图的语言数 ...
- putty 中文乱码解决方法
解决putty.exe 中文乱码的问题 export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
- TMS3705A PCF7991AT 线路图
- CarDAQ-Plus
Overview CarDAQ-Plus is the most validated and accepted J2534 device in the world. It has been on th ...