java如何定义三叉树_java — Notebook

Don’t use If¶

diff --git a/build/html/software/solr.html b/build/html/software/solr.html

new file mode 100644

index 0000000..b526292

--- /dev/null

+++ b/build/html/software/solr.html

@@ -0,0 +1,556 @@

+

+

+

+

+

+

+

+ solr — Notebook

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+ +

+

+

+

+ + notebook

+ 1

+

+

+

+ +

+

+

+

+

+

++

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

solr¶

+

+

安装¶

+

solr 5 之前,可能需要打成solr.war包,放在tomcat里启动。solr 5以后,就不支持tomcat方式启动了

+

+

requirements¶

+++

+

+

++

需求

+版本

+

+

++

java

+1.7

+

+

+

+

+

Warning

+

solr 从5开始,不支持打成war包在web container里(如tomcat)运行了, 因为它自己就是一个独立的server

+

+

+

+

+

介绍¶

+

+

solr 家目录¶

+

下载solr并解压后,那个目录是solr的安装目录。解压完就相当于安装完了,之后,需要定一个 solr 家目录, 用来放置多个core文件的目录

+

solr 启动的时候,必须指定家目录。 家目录有两个作用, 一是指定配置文件,二是放置index索引文件. 家目录结构一般如下:

+

/

+|

+|___solr.xml solr基础功能配置

+|___zoo.cfg 如果启动cloud模式,则家目录必须有这个配置(zookeeper的配置)

+|___核心1/

+ |____core.properties

+ |

+ |____conf/

+ | |__solrconfig.xml solr高级功能配置

+ | |__stopwords.txt

+ | |__protwords.txt

+ | |__synonyms.txt

+ | |__managed-schema 功能和schema.xml类似

+ | |__elevate.xml

+ | |__currency.xml

+ | |__schema.xml schema

+ |

+ |____data/

+ |___index/

+ |___tlog/

+

+

+

+

Warning

++

schema.xml 和 managed-schema 的功能一样,都是管理solr schema 的配置文件。具体solr使用哪个,要由solrconfig.xml里的

+

标签来控制. managed-schema是允许solr动态来修改schema

+

+

solr 有两种模式:

+

SolrCloud collections

+standalone cores

+

+

+

+

+

+

+

+

+

使用¶

+

+

下载solr¶

+

在终端执行:

+

wget http://archive.apache.org/dist/lucene/solr/5.0.0/solr-5.0.0.tgz -c

+

+

+

+

+

部署solr¶

+

为自己的项目增加solr, 分四步:

++

定义schema. 告诉solr增加的文档怎么增加到索引中

+

安装并启动solr, 创建core

+

填充要索引的文档。 一般是把database import 到solr里

+

向用户开放搜索接口

+

+

+

+

定义schema¶

+

SOLR加载数据,创建索引和数据时,核心数据结构的配置文件是schema.xml,该配置文件主要用于配置数据源,字段类型定义,

+搜索类型定义等。schema.xml的配置直接影响搜索结果的准确性与效率。

+

+

Warning

++

默认//conf/solrconfig.xml 里 schemaFactory=ManagedIndexSchemaFactory, 这样的话solr使用接口管理schema,

+

所以conf/schema.xml并不起作用。 修改schemaFactory=ClassicIndexSchemaFactory, 然后再创造schema.xml, 并重启solr

+

+

+

+

+

要定义field, 先要定义fieldType, fieldType 告诉solr每种类型对应的底层Java类, 例如:

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

定义fieldType时,可用的属性:

+++

+

+

++

属性名

+作用

+

+

++

name

+The name of the fieldType. This value gets used in field definitions, in the “type”

+attribute. It is strongly recommended that names consist of alphanumeric or underscore

+characters only and not start with a digit. This is not currently strictly enforced.

+

+

class

+The class name that gets used to store and index the data for this type. Note

+that you may prefix included class names with “solr.” and Solr will automatically figure

+out which packages to search for the class - so “solr.TextField” will work. If you

+are using a third-party class, you will probably need to have a fully qualified class

+name. The fully qualified equivalent for “solr.TextField” is “org.apache.solr.schema.

+TextField”.

+

+

positionIncrementGap

+For multivalued fields, specifies a distance between multiple values, which prevents

+spurious phrase matches

+

+

autoGeneratePhraseQueries

+For text fields. If true, Solr automatically generates phrase queries for adjacent terms.

+If false, terms must be enclosed in double-quotes to be treated as phrases.

+

+

docValuesFormat

+Defines a custom DocValuesFormat to use for fields of this type. This requires that a

+schema-aware codec, such as the SchemaCodecFactory has been configured in solrconfig.xml.

+

+

postingsFormat

+Defines a custom PostingsFormat to use for fields of this type. This requires that a

+schema-aware codec, such as the SchemaCodecFactory has been configured in solrconfig.xml.

+

+

indexed

+If true, the value of the field can be used in queries to retrieve matching documents

+

+

stored

+If true, the actual value of the field can be retrieved by queries

+

+

docValues

+If true, the value of the field will be put in a column-oriented DocValues structure

+

+

sortMissingFirst

+

+

+

sortMissingLast

+Control the placement of documents when a sort field is not present. As of Solr 3.5,

+these work for all numeric fields, including Trie and date fields.

+

+

multiValued

+If true, indicates that a single document might contain multiple values for this type

+

+

omitNorms

+If true, omits the norms associated with this field (this disables length normalization

+and index-time boosting for the field, and saves some memory). Defaults to true for all

+primitive (non-analyzed) field types, such as int, float, data, bool, and string. Only

+full-text fields or fields that need an index-time boost need norms.

+

+

omitTermFreqAndPositions

+If true, omits term frequency, positions, and payloads from postings for this field.

+This can be a performance boost for fields that don’t require that information. It also

+reduces the storage space required for the index. Queries that rely on position that

+are issued on a field with this option will silently fail to find documents. This

+property defaults to true for all fields that are not text fields.

+

+

omitPositions

+Similar to omitTermFreqAndPositions but preserves term frequency information

+

+

termVectors

+

+

+

termPositions

+

+

+

termOffsets

+These options instruct Solr to maintain full term vectors for each document, optionally

+including the position and offset information for each term occurrence in those vectors.

+These can be used to accelerate highlighting and other ancillary functionality,

+but impose a substantial cost in terms of index size. They are not necessary for typical

+uses of Solr

+

+

required

+Instructs Solr to reject any attempts to add a document which does not have a value for

+this field. This property defaults to false.

+

+

+

+

定义field 可用的属性:

+++

+

+

++

属性名

+作用

+

+

++

name

+mandatory - the name for the field

+

+

type

+mandatory - the name of a field type from the

+ fieldType section

+

+

indexed

+true if this field should be indexed (searchable or sortable)

+

+

stored

+true if this field should be retrievable

+

+

docValues

+true if this field should have doc values. Doc values are

+useful for faceting, grouping, sorting and function queries. Although not

+required, doc values will make the index faster to load, more

+NRT-friendly and more memory-efficient. They however come with some

+

+

limitations

+they are currently only supported by StrField, UUIDField

+and all Trie*Fields, and depending on the field type, they might

+require the field to be single-valued, be required or have a default

+value (check the documentation of the field type you’re interested in

+for more information)

+

+

multiValued

+true if this field may contain multiple values per document

+

+

omitNorms:

+(expert) set to true to omit the norms associated with

+this field (this disables length normalization and index-time

+boosting for the field, and saves some memory). Only full-text

+fields or fields that need an index-time boost need norms.

+Norms are omitted for primitive (non-analyzed) types by default.

+

+

termVectors

+[false] set to true to store the term vector for a given field.

+When using MoreLikeThis, fields used for similarity should be

+stored for best performance.

+

+

termPositions

+Store position information with the term vector. This will increase storage costs.

+

+

termOffsets

+Store offset information with the term vector. This will increase storage costs.

+

+

required

+The field is required. It will throw an error if the value does not exist

+

+

default

+a value that should be used if no value is specified when adding a document.

+

+

+

+

+

+

solr常用命令¶

+

启动停止服务:

+

# 创建一个home dir, 里面必须有solr.xml, 如果想使用cloud模式,还必须有zoo.cfg

+./bin/solr start -s

+

+./bin/solr status

+

+./bin/solr stop -p

+

+# 健康监测

+./bin/solr healthcheck -c

+

+

+

创建core:

+

./bin/solr create

+

+

+

查询接口:

+

curl http://localhost:8983/solr/gettingstarted/select?q=video

+curl http://localhost:8983/solr/core/query -d 'q=*:*'

+

+

+

更新文档:

+

# 删除所有文档

+curl http://localhost:8080/solr/update --data-binary "*:*" -H 'Content-type:text/xml; charset=utf-8'

+curl http://localhost:8080/solr/update --data-binary "" -H 'Content-type:text/xml; charset=utf-8'

+

+

+

+

+

+

扩展¶

+

solr 可以横向扩展,有两种方式:

++

cloud

+

类似于数据库的sharding 模式,把数据分布在多台server上。当一个查询来到时,先去各个机器查询结果,最后把每个机器的结果merge在一起

+

+

replica

+

类似于数据库的replica模式, 一个solr节点可以sync多份,那么对每一个slave结点,都可以查询。(可能slave结点会有延迟更新的问题)

+

+

+

优化solr的主要方式,是优化schema:

++

set stored=”false” for all fields possible (esp large fields) when you

+only need to search on the field but don’t need to return the original

+value.

+

set indexed=”false” if you don’t need to search on the field, but only

+return the field as a result of searching on other indexed fields.

+

remove all unneeded copyField statements

+

for best index size and searching performance, set “index” to false

+for all general text fields, use copyField to copy them to the

+catchall “text” field, and use that for searching.

+

For maximum indexing performance, use the ConcurrentUpdateSolrServer

+java client.

+

Remember to run the JVM in server mode, and use a higher logging level

+that avoids logging every request

+

+

+

+

+

+

+

+

+

++

+

+ Back to top

+

+

+

+

+ © Copyright 2015, xiewenlongs@gmail.com.

+ Created using Sphinx 1.2.3.

+

+

+

+

+

\ No newline at end of file

diff --git a/build/html/tools.html b/build/html/tools.html

new file mode 100644

index 0000000..549462f

--- /dev/null

+++ b/build/html/tools.html

@@ -0,0 +1,198 @@

+

+

+

+

+

+

+

+ Tools — Notebook

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+ +

+

+

+

+ + notebook

+ 1

+

+

+

+ +

+

+

+

+

+

++

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

Tools¶

+

+

Mac下提供效率的工具¶

+

Dold the command key, it will show all shortcuts in current application

+

omnifocus

+

高效的GTD任务管理工具

+

Mac下比较好用的番茄钟

+

+

+

Mac下提供效率的工具¶

+

团队任务协作平台,类似于github的可视化issue页面. 有以下功能:

++

把task assign to 某人

+

添加comments

+

label 一个任务的紧急度

+

+

+

+

+

+

+

+

+

++

+

+ Back to top

+

+

+

+

+ © Copyright 2015, xiewenlongs@gmail.com.

+ Created using Sphinx 1.2.3.

+

+

+

+

+

\ No newline at end of file

diff --git a/source/_static/s_nginx_location_tree.jpg b/source/_static/s_nginx_location_tree.jpg

index 9153762..9cb11c3 100644

Binary files a/source/_static/s_nginx_location_tree.jpg and b/source/_static/s_nginx_location_tree.jpg differ

diff --git a/source/index.rst b/source/index.rst

index 87134d2..efa2961 100644

--- a/source/index.rst

+++ b/source/index.rst

@@ -14,4 +14,5 @@

arithmetic/index

mind/index

sources

+ tools

todo

diff --git a/source/program_lang/index.rst b/source/program_lang/index.rst

index 99e1e2f..4fb572c 100644

--- a/source/program_lang/index.rst

+++ b/source/program_lang/index.rst

@@ -6,4 +6,5 @@

:titlesonly:

c

+ java

python

diff --git a/source/program_lang/java.rst b/source/program_lang/java.rst

new file mode 100644

index 0000000..576ecd3

--- /dev/null

+++ b/source/program_lang/java.rst

@@ -0,0 +1,18 @@

+===============================================

+java

+===============================================

+

+

+

+FAQ

+---------------------------------------

+

+**Ivy is not avaliable**

+

+Ivy是ant的一个插件, 报这个错说明Ivy插件没有安装,或者没有配置好.

+

+

+第一步,从官网下载Ivy tgz包并下载编译成jar包, 然后把Ivy.jar 拷贝到/usr/share/ant/lib/ 下

+

+第二步, 配置环境变量 ``ANT_HOME``, export ANT_HOME=/usr/share/ant/

+

diff --git a/source/software/index.rst b/source/software/index.rst

index 4c890ce..b82457e 100644

--- a/source/software/index.rst

+++ b/source/software/index.rst

@@ -17,5 +17,6 @@

python-lib/index

nginx/index

sentry

+ solr

vim

webbench

diff --git a/source/software/nginx/implement.rst b/source/software/nginx/implement.rst

index c32286a..0fe821a 100644

--- a/source/software/nginx/implement.rst

+++ b/source/software/nginx/implement.rst

@@ -42,6 +42,38 @@ Architecture

+nginx 把一个Http请求的处理,分为若干个步骤, 按处理顺序如下:

+

+.. cssclass:: table-bordered

+.. table::

+

+ ===================================== ================================= ==============================================

+ 步骤 模块/命令 hander

+ ===================================== ================================= ==============================================

+ server selection (*) listen, server_name

+ NGX_HTTP_POST_READ_PHASE HttpRealIpModule (第三方)

+ NGX_HTTP_SERVER_REWRITE_PHASE rewrite ngx_http_rewrite_handler (rewrite)

+ NGX_HTTP_FIND_CONFIG_PHASE (*) location

+ NGX_HTTP_REWRITE_PHASE rewrite ngx_http_rewrite_handler (rewrite)

+ NGX_HTTP_POST_REWRITE_PHASE (*)

+ NGX_HTTP_PREACCESS_PHASE degradation, limit_zone, ngx_http_limit_conn_handler (limit_conn)

+ limit req, HttpRealIpModule ngx_http_limit_req_handler (limit_req)

+ NGX_HTTP_ACCESS_PHASE allow, deny, auth_basic ngx_http_auth_basic_handler (auth_base)

+ ngx_http_access_handler (access)

+ NGX_HTTP_POST_ACCESS_PHASE (*)

+ NGX_HTTP_TRY_FILES_PHASE (*) try_files

+ NGX_HTTP_CONTENT_PHASE autoindex, Core, DAV, EmptyGif, ngx_http_static_handler (static)

+ FastCGI, FLV, gzip_static, index, ngx_http_autoindex_handler (autoindex)

+ memcached, perl, proxy, ngx_http_index_handler (index)

+ random_index, scgi, stub_status,

+ uwsgi

+ NGX_HTTP_LOG_PHASE access_log ngx_http_log_handler (log)

+ ===================================== ================================= ==============================================

+

+.. warning::

+ 其中每一个phase里每个handler的顺序是可能改变的, 由 ``ngx_module_t *ngx_modules`` 来定(auto configure 生成的)

+

+

modules

---------------------------------------

@@ -130,10 +162,19 @@ other

location tree

~~~~~~~~~~~~~~~~~~~~~~~

-There will be more than one location in on server block. To speed up search, nginx create a static tree struct before

-listening.

+对于每一个server, 里面可能有多个location 配置, 所有location 有两种可能: ``正则匹配`` 和 ``精确匹配(以它开头)``

+最简单的做法是, nginx实现一个数组,把所有location配置塞进去。一个请求到来的时候,依次遍历数组去判断.

+

+

+但是nginx要实现一个feature: 先处理 ``精确匹配``, 再处理 ``正则匹配``. 并且遍历数组的效率明显偏低. 所以解析完一个server

+下的所有location配置以后, nginx 构造了两个变量::

+

+ ngx_http_location_tree_node_t *static_locations;

+ ngx_http_core_loc_conf_t **regex_locations;

+

+static_locations 是一个平衡排序三叉树,保存了 ``精确匹配`` 的所有location, 而regex_locations是一个数组,

+保存了 ``正则匹配``. 一个请求来的时候,先遍历精确匹配的三叉树(效率很高), 如果不匹配再遍历正则匹配的数组

-|

.. image:: ../../_static/s_nginx_location_tree.jpg

diff --git a/source/software/nginx/use.rst b/source/software/nginx/use.rst

index 1d37987..7cc9290 100644

--- a/source/software/nginx/use.rst

+++ b/source/software/nginx/use.rst

@@ -146,7 +146,8 @@ event模块

connections event_core 貌似被废弃了, nginx文档里没有这个指令, 从代码看默认512

use event_core 使用那种connection processing method, nginx默认会选择最高效的方式

multi_accept event_core 当事件模型通知有新请求时,尽可能对本次调度中客户端的所有TCP请求都建立连接,

- 默认off

+ 默认off. 如果同一时间过来的请求量太大,一个worker进程会花费很多在accept上,

+ 所以这时应该关闭

accept_mutex event_core 1. ``避免惊群效果`` (每个 accept 上一把锁);

2. ``负载平衡`` (如果当前worker的请求量已达到worker_connections的7/8,

则这个worker 不参与竞争新来的request) ,默认是on

@@ -509,20 +510,67 @@ location 配置

``=`` 匹配符, 完全匹配才处理, e.g::

location = / {

- # 完全匹配才处理

+ # 完全匹配才处理, 只处理url/

...

}

-``~`` 匹配符, 表示大小写敏感

+``~`` 匹配符, 表示执行一个正则匹配, 大小写敏感

-``~*`` 匹配符, 表示大小写不敏感

+``~*`` 匹配符, 表示执行一个正则匹配, 大小写不敏感

+

+``^~`` 表示普通字符匹配,如果该选项匹配,只匹配该选项,不匹配别的选项,一般用来匹配目录

可以使用正则, e.g::

- location ~* \.(gif|png)$ {

- # 以gif 或者 png 结尾的url

+ location = / {

+ # 只匹配"/".

+ [ configuration A ]

+ }

+

+ location / {

+ # 匹配任何请求,因为所有请求都是以"/"开始

+ # 但是更长字符匹配或者正则表达式匹配会优先匹配

+ [ configuration B ]

+ }

+

+ location ^~ /images/ {

+ # 匹配任何以 /images/ 开始的请求,并停止匹配 其它location

+ [ configuration C ]

}

+ location ~* \.(gif|jpg|jpeg)$ {

+ # 匹配以 gif, jpg, or jpeg结尾的请求.

+ # 但是所有 /images/ 目录的请求将由 [Configuration C]处理.

+ [ configuration D ]

+ }

+

+

+log 配置

+~~~~~~~~~~~~~~~~~~~~~~~

+

+log配置有四个指令::

+

+ error_log logs/error.log warn;

+ log_format gzip '$remote_addr - $remote_user [$time_local] '

+ '"$request" $status $bytes_sent '

+ '"$http_referer" "$http_user_agent" "$gzip_ratio"';

+

+ access_log /spool/logs/nginx-access.log gzip buffer=32k;

+ open_log_file_cache max=1000 inactive=20s valid=1m min_uses=2;

+

+

+默认的error日志,在logs/error.log. 默认的access日志, 在logs/access.log. 可以通过 ``log_format`` 指令来定义format, 然后

+在access_log指令里用.

+

+.. warning::

+ 尽量不要在log 路径里写变量, 否则nginx 每写一条日志,都要打开关闭一次文件描述符, 虽然可以用open_log_file_cache 指令

+ 来优化这点,但还是很影响性能

+

+|

+

+写log时默认使用同level的log配置, 如果当前level没有log配置, 就继承上层配置。如果当前level有多个log配置,那么每个配置都写

+一遍

+

Don't use If

diff --git a/source/software/solr.rst b/source/software/solr.rst

new file mode 100644

index 0000000..453bf35

--- /dev/null

+++ b/source/software/solr.rst

@@ -0,0 +1,297 @@

+===============================================

+solr

+===============================================

+

+

+安装

+---------------------------------------

+

+solr 5 之前,可能需要打成solr.war包,放在tomcat里启动。solr 5以后,就不支持tomcat方式启动了

+

+

+requirements

+~~~~~~~~~~~~~~~~~~~~~~~

+

+

+.. cssclass:: table-bordered

+.. table::

+

+ =============== ===============================================

+ 需求 版本

+ =============== ===============================================

+ java 1.7

+ =============== ===============================================

+

+

+.. warning::

+

+ solr 从5开始,不支持打成war包在web container里(如tomcat)运行了, 因为它自己就是一个独立的server

+

+

+

+介绍

+---------------------------------------

+

+

+solr 家目录

+~~~~~~~~~~~~~~~~~~~~~~~

+

+下载solr并解压后,那个目录是solr的安装目录。解压完就相当于安装完了,之后,需要定一个 ``solr 家目录``, 用来放置多个core文件的目录

+

+solr 启动的时候,必须指定家目录。 家目录有两个作用, 一是指定配置文件,二是放置index索引文件. 家目录结构一般如下::

+

+ /

+ |

+ |___solr.xml solr基础功能配置

+ |___zoo.cfg 如果启动cloud模式,则家目录必须有这个配置(zookeeper的配置)

+ |___核心1/

+ |____core.properties

+ |

+ |____conf/

+ | |__solrconfig.xml solr高级功能配置

+ | |__stopwords.txt

+ | |__protwords.txt

+ | |__synonyms.txt

+ | |__managed-schema 功能和schema.xml类似

+ | |__elevate.xml

+ | |__currency.xml

+ | |__schema.xml schema

+ |

+ |____data/

+ |___index/

+ |___tlog/

+

+

+.. warning::

+ schema.xml 和 managed-schema 的功能一样,都是管理solr schema 的配置文件。具体solr使用哪个,要由solrconfig.xml里的

+ 标签来控制. managed-schema是允许solr动态来修改schema

+

+

+solr 有两种模式::

+

+ SolrCloud collections

+ standalone cores

+

+

+|

+

+使用

+---------------------------------------

+

+下载solr

+~~~~~~~~~~~~~~~~~~~~~~~

+

+在终端执行::

+

+ wget http://archive.apache.org/dist/lucene/solr/5.0.0/solr-5.0.0.tgz -c

+

+

+部署solr

+~~~~~~~~~~~~~~~~~~~~~~~

+

+为自己的项目增加solr, 分四步:

+

+* 定义schema. 告诉solr增加的文档怎么增加到索引中

+

+* 安装并启动solr, 创建core

+

+* 填充要索引的文档。 一般是把database import 到solr里

+

+* 向用户开放搜索接口

+

+

+定义schema

+~~~~~~~~~~~~~~~~~~~~~~~

+SOLR加载数据,创建索引和数据时,核心数据结构的配置文件是schema.xml,该配置文件主要用于配置数据源,字段类型定义,

+搜索类型定义等。schema.xml的配置直接影响搜索结果的准确性与效率。

+

+.. warning::

+ 默认//conf/solrconfig.xml 里 schemaFactory=ManagedIndexSchemaFactory, 这样的话solr使用接口管理schema,

+ 所以conf/schema.xml并不起作用。 修改schemaFactory=ClassicIndexSchemaFactory, 然后再创造schema.xml, 并重启solr

+

+

+|

+

+要定义field, 先要定义fieldType, fieldType 告诉solr每种类型对应的底层Java类, 例如::

+

+ + +

+

+

+

+

+ +

+

+

+

+

+

+

+

+定义fieldType时,可用的属性:

+

+.. cssclass:: table-bordered

+.. table::

+

+ ========================= ==========================================================================================

+ 属性名 作用

+ ========================= ==========================================================================================

+ name The name of the fieldType. This value gets used in field definitions, in the "type"

+ attribute. It is strongly recommended that names consist of alphanumeric or underscore

+ characters only and not start with a digit. This is not currently strictly enforced.

+ class The class name that gets used to store and index the data for this type. Note

+ that you may prefix included class names with "solr." and Solr will automatically figure

+ out which packages to search for the class - so "solr.TextField" will work. If you

+ are using a third-party class, you will probably need to have a fully qualified class

+ name. The fully qualified equivalent for "solr.TextField" is "org.apache.solr.schema.

+ TextField".

+ positionIncrementGap For multivalued fields, specifies a distance between multiple values, which prevents

+ spurious phrase matches

+ autoGeneratePhraseQueries For text fields. If true, Solr automatically generates phrase queries for adjacent terms.

+ If false, terms must be enclosed in double-quotes to be treated as phrases.

+ docValuesFormat Defines a custom DocValuesFormat to use for fields of this type. This requires that a

+ schema-aware codec, such as the SchemaCodecFactory has been configured in solrconfig.xml.

+ postingsFormat Defines a custom PostingsFormat to use for fields of this type. This requires that a

+ schema-aware codec, such as the SchemaCodecFactory has been configured in solrconfig.xml.

+ indexed If true, the value of the field can be used in queries to retrieve matching documents

+ stored If true, the actual value of the field can be retrieved by queries

+ docValues If true, the value of the field will be put in a column-oriented DocValues structure

+ sortMissingFirst

+ sortMissingLast Control the placement of documents when a sort field is not present. As of Solr 3.5,

+ these work for all numeric fields, including Trie and date fields.

+ multiValued If true, indicates that a single document might contain multiple values for this type

+ omitNorms If true, omits the norms associated with this field (this disables length normalization

+ and index-time boosting for the field, and saves some memory). Defaults to true for all

+ primitive (non-analyzed) field types, such as int, float, data, bool, and string. Only

+ full-text fields or fields that need an index-time boost need norms.

+ omitTermFreqAndPositions If true, omits term frequency, positions, and payloads from postings for this field.

+ This can be a performance boost for fields that don't require that information. It also

+ reduces the storage space required for the index. Queries that rely on position that

+ are issued on a field with this option will silently fail to find documents. This

+ property defaults to true for all fields that are not text fields.

+ omitPositions Similar to omitTermFreqAndPositions but preserves term frequency information

+ termVectors

+ termPositions

+ termOffsets These options instruct Solr to maintain full term vectors for each document, optionally

+ including the position and offset information for each term occurrence in those vectors.

+ These can be used to accelerate highlighting and other ancillary functionality,

+ but impose a substantial cost in terms of index size. They are not necessary for typical

+ uses of Solr

+ required Instructs Solr to reject any attempts to add a document which does not have a value for

+ this field. This property defaults to false.

+ ========================= ==========================================================================================

+

+.. tip::

+ 各种属性的使用场景,可以参考: https://cwiki.apache.org/confluence/display/solr/Field+Properties+by+Use+Case

+

+

+定义field 可用的属性:

+

+.. cssclass:: table-bordered

+.. table::

+

+ =============== ==========================================================================================

+ 属性名 作用

+ =============== ==========================================================================================

+ name mandatory - the name for the field

+ type mandatory - the name of a field type from the

+ fieldType section

+ indexed true if this field should be indexed (searchable or sortable)

+ stored true if this field should be retrievable

+ docValues true if this field should have doc values. Doc values are

+ useful for faceting, grouping, sorting and function queries. Although not

+ required, doc values will make the index faster to load, more

+ NRT-friendly and more memory-efficient. They however come with some

+ limitations they are currently only supported by StrField, UUIDField

+ and all Trie*Fields, and depending on the field type, they might

+ require the field to be single-valued, be required or have a default

+ value (check the documentation of the field type you're interested in

+ for more information)

+ multiValued true if this field may contain multiple values per document

+ omitNorms: (expert) set to true to omit the norms associated with

+ this field (this disables length normalization and index-time

+ boosting for the field, and saves some memory). Only full-text

+ fields or fields that need an index-time boost need norms.

+ Norms are omitted for primitive (non-analyzed) types by default.

+ termVectors [false] set to true to store the term vector for a given field.

+ When using MoreLikeThis, fields used for similarity should be

+ stored for best performance.

+ termPositions Store position information with the term vector. This will increase storage costs.

+ termOffsets Store offset information with the term vector. This will increase storage costs.

+ required The field is required. It will throw an error if the value does not exist

+ default a value that should be used if no value is specified when adding a document.

+ =============== ==========================================================================================

+

+

+solr常用命令

+~~~~~~~~~~~~~~~~~~~~~~~

+

+

+启动停止服务::

+

+ # 创建一个home dir, 里面必须有solr.xml, 如果想使用cloud模式,还必须有zoo.cfg

+ ./bin/solr start -s +

+ ./bin/solr status

+

+ ./bin/solr stop -p +

+ # 健康监测

+ ./bin/solr healthcheck -c +

+

+创建core::

+

+ ./bin/solr create +

+

+查询接口::

+

+ curl http://localhost:8983/solr/gettingstarted/select?q=video

+ curl http://localhost:8983/solr/core/query -d 'q=*:*'

+

+

+更新文档::

+

+ # 删除所有文档

+ curl http://localhost:8080/solr/update --data-binary "*:*" -H 'Content-type:text/xml; charset=utf-8'

+ curl http://localhost:8080/solr/update --data-binary "" -H 'Content-type:text/xml; charset=utf-8'

+

+扩展

+---------------------------------------

+

+solr 可以横向扩展,有两种方式:

+

+* cloud

+

+ 类似于数据库的sharding 模式,把数据分布在多台server上。当一个查询来到时,先去各个机器查询结果,最后把每个机器的结果merge在一起

+

+* replica

+

+ 类似于数据库的replica模式, 一个solr节点可以sync多份,那么对每一个slave结点,都可以查询。(可能slave结点会有延迟更新的问题)

+

+

+优化solr的主要方式,是优化schema:

+

+- set stored="false" for all fields possible (esp large fields) when you

+ only need to search on the field but don't need to return the original

+ value.

+

+- set indexed="false" if you don't need to search on the field, but only

+ return the field as a result of searching on other indexed fields.

+

+- remove all unneeded copyField statements

+

+- for best index size and searching performance, set "index" to false

+ for all general text fields, use copyField to copy them to the

+ catchall "text" field, and use that for searching.

+

+- For maximum indexing performance, use the ConcurrentUpdateSolrServer

+ java client.

+

+- Remember to run the JVM in server mode, and use a higher logging level

+ that avoids logging every request

diff --git a/source/tools.rst b/source/tools.rst

new file mode 100644

index 0000000..6e4a055

--- /dev/null

+++ b/source/tools.rst

@@ -0,0 +1,34 @@

+===============================================

+Tools

+===============================================

+

+

+Mac下提供效率的工具

+---------------------------------------

+

+`cheatsheet `_

+

+Dold the ``command`` key, it will show all shortcuts in current application

+

+

+omnifocus

+

+高效的GTD任务管理工具

+

+`pomotodo `_

+

+Mac下比较好用的番茄钟

+

+

+Mac下提供效率的工具

+---------------------------------------

+

+`trello `_

+

+团队任务协作平台,类似于github的可视化issue页面. 有以下功能:

+

+- 把task assign to 某人

+

+- 添加comments

+

+- label 一个任务的紧急度

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值