├── guide
├── cmd
│ ├── root
│ ├── watch
│ ├── index.html
│ ├── imports
│ │ ├── _oa.scss
│ │ ├── _oa-import.scss
│ │ ├── functions
│ │ │ ├── _oa-textarea.scss
│ │ │ ├── _oa-hyperlink.scss
│ │ │ ├── _oa-alert.scss
│ │ │ ├── _oa-input.scss
│ │ │ └── _oa-load.scss
│ │ ├── _oa-config.scss
│ │ └── _oa-mixins.scss
│ ├── package.json
│ ├── config.rb
│ ├── gulpfile.js
│ ├── command
│ └── libs
│ │ └── functions.php
├── img
│ ├── 01.png
│ ├── 02.png
│ ├── 03.png
│ ├── 04.png
│ ├── 05.png
│ ├── 06.png
│ ├── 07.png
│ ├── 08.png
│ ├── 09.png
│ ├── 10.png
│ ├── og
│ │ ├── index.png
│ │ ├── read.png
│ │ ├── create.png
│ │ ├── delete.png
│ │ ├── install.png
│ │ ├── struct.png
│ │ └── update.png
│ └── bg
│ │ ├── grunge.png
│ │ ├── grunge_ori.png
│ │ └── lightgrunge.png
├── font
│ ├── monaco
│ │ ├── font.png
│ │ ├── monaco.otf
│ │ ├── monaco.ttf
│ │ ├── index.html
│ │ └── README
│ └── icomoon
│ │ ├── icomoon.eot
│ │ ├── icomoon.ttf
│ │ ├── icomoon.woff
│ │ └── icomoon
│ │ ├── fonts
│ │ ├── icomoon.eot
│ │ ├── icomoon.ttf
│ │ └── icomoon.woff
│ │ ├── Read Me.txt
│ │ ├── demo-files
│ │ ├── demo.js
│ │ └── demo.css
│ │ └── style.css
├── js
│ └── prettify
│ │ ├── index.html
│ │ ├── lang-rd.js
│ │ ├── lang-go.js
│ │ ├── lang-tex.js
│ │ ├── lang-proto.js
│ │ ├── lang-llvm.js
│ │ ├── lang-yaml.js
│ │ ├── lang-basic.js
│ │ ├── lang-wiki.js
│ │ ├── lang-lua.js
│ │ ├── lang-hs.js
│ │ ├── lang-erlang.js
│ │ ├── lang-tcl.js
│ │ ├── lang-r.js
│ │ ├── lang-pascal.js
│ │ ├── lang-lisp.js
│ │ ├── lang-css.js
│ │ ├── lang-mumps.js
│ │ ├── lang-scala.js
│ │ ├── lang-dart.js
│ │ ├── lang-apollo.js
│ │ ├── lang-ml.js
│ │ ├── lang-n.js
│ │ ├── lang-vhdl.js
│ │ ├── lang-clj.js
│ │ ├── lang-vb.js
│ │ ├── lang-sql.js
│ │ └── prettify.css
├── css
│ └── prettify
│ │ └── prettify.css
├── scss
│ └── prettify
│ │ └── prettify.scss
└── delete.html
├── .gitignore
├── demo
├── Elastica
│ ├── Exception
│ │ ├── Invalid.php
│ │ ├── NotFound.php
│ │ ├── Abstract.php
│ │ ├── NotImplemented.php
│ │ ├── Response.php
│ │ ├── BulkResponse.php
│ │ └── Client.php
│ ├── Query
│ │ ├── Abstract.php
│ │ ├── MatchAll.php
│ │ ├── Match.php
│ │ ├── Fuzzy.php
│ │ ├── Range.php
│ │ ├── Wildcard.php
│ │ ├── Nested.php
│ │ ├── Array.php
│ │ ├── CustomScore.php
│ │ ├── ConstantScore.php
│ │ ├── HasChild.php
│ │ ├── Term.php
│ │ ├── Prefix.php
│ │ ├── TopChildren.php
│ │ ├── CustomFiltersScore.php
│ │ ├── Filtered.php
│ │ ├── Field.php
│ │ ├── Text.php
│ │ ├── Terms.php
│ │ ├── Bool.php
│ │ ├── Ids.php
│ │ └── FuzzyLikeThis.php
│ ├── Filter
│ │ ├── Or.php
│ │ ├── And.php
│ │ ├── NumericRange.php
│ │ ├── MatchAll.php
│ │ ├── Exists.php
│ │ ├── Missing.php
│ │ ├── Limit.php
│ │ ├── Not.php
│ │ ├── Nested.php
│ │ ├── Term.php
│ │ ├── GeoPolygon.php
│ │ ├── Abstract.php
│ │ ├── Type.php
│ │ ├── HasChild.php
│ │ ├── Range.php
│ │ ├── GeoBoundingBox.php
│ │ ├── Abstract
│ │ │ └── Multi.php
│ │ ├── Prefix.php
│ │ ├── Script.php
│ │ ├── Terms.php
│ │ ├── Query.php
│ │ ├── Ids.php
│ │ └── Bool.php
│ ├── Facet
│ │ ├── Query.php
│ │ ├── Filter.php
│ │ ├── DateHistogram.php
│ │ ├── Statistical.php
│ │ ├── TermsStats.php
│ │ ├── GeoDistance.php
│ │ ├── Histogram.php
│ │ ├── Terms.php
│ │ └── Abstract.php
│ ├── Transport
│ │ ├── Https.php
│ │ ├── Abstract.php
│ │ └── Memcache.php
│ ├── Searchable.php
│ ├── ScriptFields.php
│ ├── Script.php
│ ├── Percolator.php
│ ├── Index
│ │ ├── Stats.php
│ │ └── Status.php
│ ├── Node
│ │ ├── Stats.php
│ │ └── Info.php
│ ├── Log.php
│ ├── Node.php
│ ├── Util.php
│ └── Param.php
└── searches
│ └── User.php
├── index.html
└── readme.md
/guide/cmd/root:
--------------------------------------------------------------------------------
1 | ../
--------------------------------------------------------------------------------
/guide/cmd/watch:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/guide/img/01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/img/01.png
--------------------------------------------------------------------------------
/guide/img/02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/img/02.png
--------------------------------------------------------------------------------
/guide/img/03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/img/03.png
--------------------------------------------------------------------------------
/guide/img/04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/img/04.png
--------------------------------------------------------------------------------
/guide/img/05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/img/05.png
--------------------------------------------------------------------------------
/guide/img/06.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/img/06.png
--------------------------------------------------------------------------------
/guide/img/07.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/img/07.png
--------------------------------------------------------------------------------
/guide/img/08.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/img/08.png
--------------------------------------------------------------------------------
/guide/img/09.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/img/09.png
--------------------------------------------------------------------------------
/guide/img/10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/img/10.png
--------------------------------------------------------------------------------
/guide/img/og/index.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/img/og/index.png
--------------------------------------------------------------------------------
/guide/img/og/read.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/img/og/read.png
--------------------------------------------------------------------------------
/guide/img/bg/grunge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/img/bg/grunge.png
--------------------------------------------------------------------------------
/guide/img/og/create.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/img/og/create.png
--------------------------------------------------------------------------------
/guide/img/og/delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/img/og/delete.png
--------------------------------------------------------------------------------
/guide/img/og/install.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/img/og/install.png
--------------------------------------------------------------------------------
/guide/img/og/struct.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/img/og/struct.png
--------------------------------------------------------------------------------
/guide/img/og/update.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/img/og/update.png
--------------------------------------------------------------------------------
/guide/font/monaco/font.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/font/monaco/font.png
--------------------------------------------------------------------------------
/guide/img/bg/grunge_ori.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/img/bg/grunge_ori.png
--------------------------------------------------------------------------------
/guide/font/icomoon/icomoon.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/font/icomoon/icomoon.eot
--------------------------------------------------------------------------------
/guide/font/icomoon/icomoon.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/font/icomoon/icomoon.ttf
--------------------------------------------------------------------------------
/guide/font/monaco/monaco.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/font/monaco/monaco.otf
--------------------------------------------------------------------------------
/guide/font/monaco/monaco.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/font/monaco/monaco.ttf
--------------------------------------------------------------------------------
/guide/img/bg/lightgrunge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/img/bg/lightgrunge.png
--------------------------------------------------------------------------------
/guide/font/icomoon/icomoon.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/font/icomoon/icomoon.woff
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | sftp-config*
3 |
4 | guide/cmd/.sass-cache/*
5 |
6 | guide/cmd/node_modules/*
7 | guide/cmd/npm-debug.log
8 |
--------------------------------------------------------------------------------
/guide/font/icomoon/icomoon/fonts/icomoon.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/font/icomoon/icomoon/fonts/icomoon.eot
--------------------------------------------------------------------------------
/guide/font/icomoon/icomoon/fonts/icomoon.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/font/icomoon/icomoon/fonts/icomoon.ttf
--------------------------------------------------------------------------------
/guide/font/icomoon/icomoon/fonts/icomoon.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oawu/OA-ElasticaSearch/HEAD/guide/font/icomoon/icomoon/fonts/icomoon.woff
--------------------------------------------------------------------------------
/guide/cmd/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | 403 Forbidden
4 |
5 |
6 |
7 | Directory access is forbidden.
8 |
9 |
10 |
--------------------------------------------------------------------------------
/guide/js/prettify/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | 403 Forbidden
4 |
5 |
6 |
7 | Directory access is forbidden.
8 |
9 |
10 |
--------------------------------------------------------------------------------
/guide/cmd/imports/_oa.scss:
--------------------------------------------------------------------------------
1 | /**
2 | * @author OA Wu
3 | * @copyright Copyright (c) 2016 OA Wu Design
4 | */
5 |
6 | @import "_oa-config";
7 | @import "_oa-import";
8 | @import "_oa-mixins";
9 |
--------------------------------------------------------------------------------
/guide/font/monaco/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/demo/Elastica/Exception/Invalid.php:
--------------------------------------------------------------------------------
1 |
8 | */
9 | class Elastica_Exception_Invalid extends Elastica_Exception_Abstract
10 | {
11 | }
12 |
--------------------------------------------------------------------------------
/demo/Elastica/Exception/NotFound.php:
--------------------------------------------------------------------------------
1 |
8 | */
9 | class Elastica_Exception_NotFound extends Elastica_Exception_Abstract
10 | {
11 | }
12 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-rd.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["com",/^%[^\n\r]*/,null,"%"]],[["lit",/^\\(?:cr|l?dots|R|tab)\b/],["kwd",/^\\[@-Za-z]+/],["kwd",/^#(?:ifn?def|endif)/],["pln",/^\\[{}]/],["pun",/^[()[\]{}]+/]]),["Rd","rd"]);
2 |
--------------------------------------------------------------------------------
/demo/Elastica/Exception/Abstract.php:
--------------------------------------------------------------------------------
1 |
8 | */
9 | abstract class Elastica_Exception_Abstract extends Exception
10 | {
11 | }
12 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-go.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["pln",/^(?:"(?:[^"\\]|\\[\S\s])*(?:"|$)|'(?:[^'\\]|\\[\S\s])+(?:'|$)|`[^`]*(?:`|$))/,null,"\"'"]],[["com",/^(?:\/\/[^\n\r]*|\/\*[\S\s]*?\*\/)/],["pln",/^(?:[^"'/`]|\/(?![*/]))+/]]),["go"]);
2 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/Abstract.php:
--------------------------------------------------------------------------------
1 |
8 | */
9 | abstract class Elastica_Query_Abstract extends Elastica_Param
10 | {
11 | }
12 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-tex.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["com",/^%[^\n\r]*/,null,"%"]],[["kwd",/^\\[@-Za-z]+/],["kwd",/^\\./],["typ",/^[$&]/],["lit",/[+-]?(?:\.\d+|\d+(?:\.\d*)?)(cm|em|ex|in|pc|pt|bp|mm)/i],["pun",/^[()=[\]{}]+/]]),["latex","tex"]);
2 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-proto.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.sourceDecorator({keywords:"bytes,default,double,enum,extend,extensions,false,group,import,max,message,option,optional,package,repeated,required,returns,rpc,service,syntax,to,true",types:/^(bool|(double|s?fixed|[su]?int)(32|64)|float|string)\b/,cStyleComments:!0}),["proto"]);
2 |
--------------------------------------------------------------------------------
/guide/cmd/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "gulp",
3 | "version": "3.8.9",
4 | "description": "F2E",
5 | "author": "OA Wu",
6 | "email": "comdan66@gmail",
7 | "devDependencies": {
8 | "gulp": "^3.8.9",
9 | "gulp-livereload": "^2.1.1",
10 | "gulp-uglify": "^0.3.1",
11 | "gulp-html-minifier": "^0.1.6",
12 | "del": "^0.1.0"
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/demo/Elastica/Exception/NotImplemented.php:
--------------------------------------------------------------------------------
1 |
10 | */
11 | class Elastica_Exception_NotImplemented extends Elastica_Exception_Abstract
12 | {
13 | }
14 |
--------------------------------------------------------------------------------
/demo/searches/User.php:
--------------------------------------------------------------------------------
1 |
5 | * @copyright Copyright (c) 2015 OA Wu Design
6 | */
7 |
8 | class User extends ElasticaSearch {
9 | static $primary_key = 'id';
10 | static $type_name = 'users';
11 |
12 | public function __construct ($data = array ()) {
13 | parent::__construct ($data);
14 | }
15 | }
--------------------------------------------------------------------------------
/guide/js/prettify/lang-llvm.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["str",/^!?"(?:[^"\\]|\\[\S\s])*(?:"|$)/,null,'"'],["com",/^;[^\n\r]*/,null,";"]],[["pln",/^[!%@](?:[$\-.A-Z_a-z][\w$\-.]*|\d+)/],["kwd",/^[^\W\d]\w*/,null],["lit",/^\d+\.\d+/],["lit",/^(?:\d+|0[Xx][\dA-Fa-f]+)/],["pun",/^[(-*,:<->[\]{}]|\.\.\.$/]]),["llvm","ll"]);
2 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/Or.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/or-filter.html
10 | */
11 | class Elastica_Filter_Or extends Elastica_Filter_Abstract_Multi
12 | {
13 | }
14 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/And.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/and-filter.html
10 | */
11 | class Elastica_Filter_And extends Elastica_Filter_Abstract_Multi
12 | {
13 | }
14 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/NumericRange.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/numeric-range-filter.html
10 | */
11 | class Elastica_Filter_NumericRange extends Elastica_Filter_Range
12 | {
13 | }
14 |
--------------------------------------------------------------------------------
/guide/font/icomoon/icomoon/Read Me.txt:
--------------------------------------------------------------------------------
1 | Open *demo.html* to see a list of all the glyphs in your font along with their codes/ligatures.
2 |
3 | You won't need any of the files located under the *demo-files* directory when including the generated font in your own projects.
4 |
5 | You can import *selection.json* back to the IcoMoon app using the *Import Icons* button (or via Main Menu > Manage Projects) to retrieve your icon selection.
6 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-yaml.js:
--------------------------------------------------------------------------------
1 | var a=null;
2 | PR.registerLangHandler(PR.createSimpleLexer([["pun",/^[:>?|]+/,a,":|>?"],["dec",/^%(?:YAML|TAG)[^\n\r#]+/,a,"%"],["typ",/^&\S+/,a,"&"],["typ",/^!\S*/,a,"!"],["str",/^"(?:[^"\\]|\\.)*(?:"|$)/,a,'"'],["str",/^'(?:[^']|'')*(?:'|$)/,a,"'"],["com",/^#[^\n\r]*/,a,"#"],["pln",/^\s+/,a," \t\r\n"]],[["dec",/^(?:---|\.\.\.)(?:[\n\r]|$)/],["pun",/^-/],["kwd",/^\w+:[\n\r ]/],["pln",/^\w+/]]),["yaml","yml"]);
3 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-basic.js:
--------------------------------------------------------------------------------
1 | var a=null;
2 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^"(?:[^\n\r"\\]|\\.)*(?:"|$)/,a,'"'],["pln",/^\s+/,a," \r\n\t\u00a0"]],[["com",/^REM[^\n\r]*/,a],["kwd",/^\b(?:AND|CLOSE|CLR|CMD|CONT|DATA|DEF ?FN|DIM|END|FOR|GET|GOSUB|GOTO|IF|INPUT|LET|LIST|LOAD|NEW|NEXT|NOT|ON|OPEN|OR|POKE|PRINT|READ|RESTORE|RETURN|RUN|SAVE|STEP|STOP|SYS|THEN|TO|VERIFY|WAIT)\b/,a],["pln",/^[a-z][^\W_]?(?:\$|%)?/i,a],["lit",/^(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?/i,a,"0123456789"],["pun",
3 | /^.[^\s\w"$%.]*/,a]]),["basic","cbm"]);
4 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/MatchAll.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/match-all-filter.html
10 | */
11 | class Elastica_Filter_MatchAll extends Elastica_Filter_Abstract
12 | {
13 | /**
14 | * Creates match all filter
15 | */
16 | public function __construct()
17 | {
18 | $this->_params = new stdClass();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-wiki.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\d\t a-gi-z\xa0]+/,null,"\t \u00a0abcdefgijklmnopqrstuvwxyz0123456789"],["pun",/^[*=[\]^~]+/,null,"=*~^[]"]],[["lang-wiki.meta",/(?:^^|\r\n?|\n)(#[a-z]+)\b/],["lit",/^[A-Z][a-z][\da-z]+[A-Z][a-z][^\W_]+\b/],["lang-",/^{{{([\S\s]+?)}}}/],["lang-",/^`([^\n\r`]+)`/],["str",/^https?:\/\/[^\s#/?]*(?:\/[^\s#?]*)?(?:\?[^\s#]*)?(?:#\S*)?/i],["pln",/^(?:\r\n|[\S\s])[^\n\r#*=A-[^`h{~]*/]]),["wiki"]);
2 | PR.registerLangHandler(PR.createSimpleLexer([["kwd",/^#[a-z]+/i,null,"#"]],[]),["wiki.meta"]);
3 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/MatchAll.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/match-all-query.html
10 | */
11 | class Elastica_Query_MatchAll extends Elastica_Query_Abstract
12 | {
13 | /**
14 | * Creates match all query
15 | */
16 | public function __construct()
17 | {
18 | $this->_params = new stdClass();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-lua.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["str",/^(?:"(?:[^"\\]|\\[\S\s])*(?:"|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$))/,null,"\"'"]],[["com",/^--(?:\[(=*)\[[\S\s]*?(?:]\1]|$)|[^\n\r]*)/],["str",/^\[(=*)\[[\S\s]*?(?:]\1]|$)/],["kwd",/^(?:and|break|do|else|elseif|end|false|for|function|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/,null],["lit",/^[+-]?(?:0x[\da-f]+|(?:\.\d+|\d+(?:\.\d*)?)(?:e[+-]?\d+)?)/i],
2 | ["pln",/^[_a-z]\w*/i],["pun",/^[^\w\t\n\r \xa0][^\w\t\n\r "'+=\xa0-]*/]]),["lua"]);
3 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-hs.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t-\r ]+/,null,"\t\n\u000b\u000c\r "],["str",/^"(?:[^\n\f\r"\\]|\\[\S\s])*(?:"|$)/,null,'"'],["str",/^'(?:[^\n\f\r'\\]|\\[^&])'?/,null,"'"],["lit",/^(?:0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)/i,null,"0123456789"]],[["com",/^(?:--+[^\n\f\r]*|{-(?:[^-]|-+[^}-])*-})/],["kwd",/^(?:case|class|data|default|deriving|do|else|if|import|in|infix|infixl|infixr|instance|let|module|newtype|of|then|type|where|_)(?=[^\d'A-Za-z]|$)/,
2 | null],["pln",/^(?:[A-Z][\w']*\.)*[A-Za-z][\w']*/],["pun",/^[^\d\t-\r "'A-Za-z]+/]]),["hs"]);
3 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-erlang.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t-\r ]+/,null,"\t\n\u000b\u000c\r "],["str",/^"(?:[^\n\f\r"\\]|\\[\S\s])*(?:"|$)/,null,'"'],["lit",/^[a-z]\w*/],["lit",/^'(?:[^\n\f\r'\\]|\\[^&])+'?/,null,"'"],["lit",/^\?[^\t\n ({]+/,null,"?"],["lit",/^(?:0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)/i,null,"0123456789"]],[["com",/^%[^\n]*/],["kwd",/^(?:module|attributes|do|let|in|letrec|apply|call|primop|case|of|end|when|fun|try|catch|receive|after|char|integer|float,atom,string,var)\b/],
2 | ["kwd",/^-[_a-z]+/],["typ",/^[A-Z_]\w*/],["pun",/^[,.;]/]]),["erlang","erl"]);
3 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/Match.php:
--------------------------------------------------------------------------------
1 |
5 | * @copyright Copyright (c) 2015 OA Wu Design
6 | */
7 |
8 | class Elastica_Query_Match extends Elastica_Query_Abstract
9 | {
10 |
11 | public function __construct(array $term = array())
12 | {
13 | $this->setRawTerm($term);
14 | }
15 |
16 | public function setRawTerm(array $term)
17 | {
18 | return $this->setParams($term);
19 | }
20 |
21 | public function setMatch($key, $value)
22 | {
23 | return $this->setRawTerm(array($key => $value));
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-tcl.js:
--------------------------------------------------------------------------------
1 | var a=null;
2 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^{+/,a,"{"],["clo",/^}+/,a,"}"],["com",/^#[^\n\r]*/,a,"#"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \u00a0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["kwd",/^(?:after|append|apply|array|break|case|catch|continue|error|eval|exec|exit|expr|for|foreach|if|incr|info|proc|return|set|switch|trace|uplevel|upvar|while)\b/,a],["lit",/^[+-]?(?:[#0]x[\da-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[de][+-]?\d+)?)/i],["lit",
3 | /^'(?:-*(?:\w|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[_a-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/i],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["tcl"]);
4 |
--------------------------------------------------------------------------------
/demo/Elastica/Facet/Query.php:
--------------------------------------------------------------------------------
1 |
8 | * @link http://www.elasticsearch.org/guide/reference/api/search/facets/query-facet.html
9 | */
10 | class Elastica_Facet_Query extends Elastica_Facet_Abstract
11 | {
12 | /**
13 | * Set the query for the facet.
14 | *
15 | * @param Elastica_Query_Abstract $query
16 | * @return Elastica_Facet_Query
17 | */
18 | public function setQuery(Elastica_Query_Abstract $query)
19 | {
20 | return $this->_setFacetParam('query', $query->toArray());
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/demo/Elastica/Facet/Filter.php:
--------------------------------------------------------------------------------
1 |
8 | * @link http://www.elasticsearch.org/guide/reference/api/search/facets/filter-facet.html
9 | */
10 | class Elastica_Facet_Filter extends Elastica_Facet_Abstract
11 | {
12 | /**
13 | * Set the filter for the facet.
14 | *
15 | * @param Elastica_Filter_Abstract $filter
16 | * @return Elastica_Facet_Filter
17 | */
18 | public function setFilter(Elastica_Filter_Abstract $filter)
19 | {
20 | return $this->_setFacetParam('filter', $filter->toArray());
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/demo/Elastica/Transport/Https.php:
--------------------------------------------------------------------------------
1 |
8 | */
9 | class Elastica_Transport_Https extends Elastica_Transport_Http
10 | {
11 | /**
12 | * Https scheme
13 | *
14 | * @var string https scheme
15 | */
16 | protected $_scheme = 'https';
17 |
18 | /**
19 | * Overloads setupCurl to set SSL params
20 | *
21 | * @param resource $connection Curl connection resource
22 | */
23 | protected function _setupCurl($connection)
24 | {
25 | parent::_setupCurl($connection);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-r.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,null,'"'],["str",/^'(?:[^'\\]|\\[\S\s])*(?:'|$)/,null,"'"]],[["com",/^#.*/],["kwd",/^(?:if|else|for|while|repeat|in|next|break|return|switch|function)(?![\w.])/],["lit",/^0[Xx][\dA-Fa-f]+([Pp]\d+)?[Li]?/],["lit",/^[+-]?(\d+(\.\d+)?|\.\d+)([Ee][+-]?\d+)?[Li]?/],["lit",/^(?:NULL|NA(?:_(?:integer|real|complex|character)_)?|Inf|TRUE|FALSE|NaN|\.\.(?:\.|\d+))(?![\w.])/],
2 | ["pun",/^(?:<-|->>?|-|==|<=|>=|<|>|&&?|!=|\|\|?|[!*+/^]|%.*?%|[$=@~]|:{1,3}|[(),;?[\]{}])/],["pln",/^(?:[A-Za-z]+[\w.]*|\.[^\W\d][\w.]*)(?![\w.])/],["str",/^`.+`/]]),["r","s","R","S","Splus"]);
3 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-pascal.js:
--------------------------------------------------------------------------------
1 | var a=null;
2 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^'(?:[^\n\r'\\]|\\.)*(?:'|$)/,a,"'"],["pln",/^\s+/,a," \r\n\t\u00a0"]],[["com",/^\(\*[\S\s]*?(?:\*\)|$)|^{[\S\s]*?(?:}|$)/,a],["kwd",/^(?:absolute|and|array|asm|assembler|begin|case|const|constructor|destructor|div|do|downto|else|end|external|for|forward|function|goto|if|implementation|in|inline|interface|interrupt|label|mod|not|object|of|or|packed|procedure|program|record|repeat|set|shl|shr|then|to|type|unit|until|uses|var|virtual|while|with|xor)\b/i,a],
3 | ["lit",/^(?:true|false|self|nil)/i,a],["pln",/^[a-z][^\W_]*/i,a],["lit",/^(?:\$[\da-f]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)/i,a,"0123456789"],["pun",/^.[^\s\w$'./@]*/,a]]),["pascal"]);
4 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/Fuzzy.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/fuzzy-query.html
10 | */
11 | class Elastica_Query_Fuzzy extends Elastica_Query_Abstract
12 | {
13 | /**
14 | * Adds field to fuzzy query
15 | *
16 | * @param string $fieldName Field name
17 | * @param array $args Data array
18 | * @return Elastica_Query_Fuzzy Current object
19 | */
20 | public function addField($fieldName, array $args)
21 | {
22 | return $this->setParam($fieldName, $args);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/guide/font/monaco/README:
--------------------------------------------------------------------------------
1 | monaco.ttf
2 | ==========
3 |
4 | The original monaco.ttf improved: add some special characters (which are from "DejaVu Sans Mono")
5 |
6 | In my work environment, I need connect to Linux system from Windows system remotely using SecureCRT or Putty, and edit files using VIM tools. So I need one beautiful font in SecureCRT / Putty.
7 |
8 | In windows system, there are some original fonts are beautiful, for example "Consolas", but they can't support some special characters, for example: ▸, ↪, ⌴. Because they are original fonts in my Windows, I don't want to modify them.
9 |
10 | I get "Monaco" from web. It is tiny and beautiful. But it also can't support those special characters.
11 |
12 | So I add the characters by myself and share it.
13 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/Range.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/range-query.html
10 | */
11 | class Elastica_Query_Range extends Elastica_Query_Abstract
12 | {
13 | /**
14 | * Adds a range field to the query
15 | *
16 | * @param string $fieldName Field name
17 | * @param array $args Field arguments
18 | * @return Elastica_Query_Range Current object
19 | */
20 | public function addField($fieldName, array $args)
21 | {
22 | return $this->setParam($fieldName, $args);
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/guide/cmd/imports/_oa-import.scss:
--------------------------------------------------------------------------------
1 | /**
2 | * @author OA Wu
3 | * @copyright Copyright (c) 2016 OA Wu Design
4 | */
5 |
6 | @import "compass/css3/box-shadow";
7 | @import "compass/css3/box-sizing";
8 | @import "compass/css3/selection";
9 | @import "compass/css3/font-face";
10 | @import "compass/css3/text-shadow";
11 | @import "compass/css3/border-radius";
12 | @import "compass/css3/animation";
13 | @import "compass/css3/transform";
14 | @import "compass/css3/opacity";
15 | @import "compass/css3/images";
16 | @import "compass/css3/user-interface";
17 | @import "compass/css3/transition";
18 | @import "compass/css3/background-size";
19 | @import "compass/css3/filter";
20 | @import "compass/css3/background-clip";
21 | @import "compass/css3/appearance"
22 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-lisp.js:
--------------------------------------------------------------------------------
1 | var a=null;
2 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,a,"("],["clo",/^\)+/,a,")"],["com",/^;[^\n\r]*/,a,";"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \u00a0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/,a],
3 | ["lit",/^[+-]?(?:[#0]x[\da-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[de][+-]?\d+)?)/i],["lit",/^'(?:-*(?:\w|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[_a-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/i],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["cl","el","lisp","lsp","scm","ss","rkt"]);
4 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/Exists.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/exists-filter.html
10 | */
11 | class Elastica_Filter_Exists extends Elastica_Filter_Abstract
12 | {
13 | /**
14 | * Construct exists filter
15 | *
16 | * @param string $field
17 | */
18 | public function __construct($field)
19 | {
20 | $this->setField($field);
21 | }
22 |
23 | /**
24 | * Set field
25 | *
26 | * @param string $field
27 | * @return Elastica_Filter_Exists
28 | */
29 | public function setField($field)
30 | {
31 | return $this->setParam('field', $field);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-css.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n\u000c"]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]+)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],
2 | ["com",/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}\b/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]);
3 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/Missing.php:
--------------------------------------------------------------------------------
1 |
10 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/missing-filter.html
11 | */
12 | class Elastica_Filter_Missing extends Elastica_Filter_Abstract
13 | {
14 | /**
15 | * Construct missing filter
16 | *
17 | * @param string $field OPTIONAL
18 | */
19 | public function __construct($field = '')
20 | {
21 | if (strlen($field)) {
22 | $this->setField($field);
23 | }
24 | }
25 |
26 | /**
27 | * Set field
28 | *
29 | * @param string $field
30 | */
31 | public function setField($field)
32 | {
33 | return $this->setParam('field', (string) $field);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/guide/cmd/imports/functions/_oa-textarea.scss:
--------------------------------------------------------------------------------
1 | /**
2 | * @author OA Wu
3 | * @copyright Copyright (c) 2016 OA Wu Design
4 | */
5 |
6 | @mixin textarea () {
7 | width: 250px;
8 | height: 80px;
9 | padding: 5px;
10 | border: 1px solid rgba(39, 40, 34, .25);
11 | font-size: 16px;
12 | color: rgba(50, 50, 50, 0.7);
13 | resize: none;
14 | @include border-radius (2px);
15 | @include transition(all .3s);
16 |
17 | &:focus {
18 | outline: 0;
19 | border: 1px solid rgba(102, 175, 233, 1);
20 | @include box-shadow(inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6));
21 | }
22 | }
23 | @mixin textarea-error () {
24 | border-color: #a94442;
25 | box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
26 |
27 | &:focus {
28 | border-color: #843534;
29 | box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #ce8483;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-mumps.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["str",/^"(?:[^"]|\\.)*"/,null,'"']],[["com",/^;[^\n\r]*/,null,";"],["dec",/^\$(?:d|device|ec|ecode|es|estack|et|etrap|h|horolog|i|io|j|job|k|key|p|principal|q|quit|st|stack|s|storage|sy|system|t|test|tl|tlevel|tr|trestart|x|y|z[a-z]*|a|ascii|c|char|d|data|e|extract|f|find|fn|fnumber|g|get|j|justify|l|length|na|name|o|order|p|piece|ql|qlength|qs|qsubscript|q|query|r|random|re|reverse|s|select|st|stack|t|text|tr|translate|nan)\b/i,
2 | null],["kwd",/^(?:[^$]b|break|c|close|d|do|e|else|f|for|g|goto|h|halt|h|hang|i|if|j|job|k|kill|l|lock|m|merge|n|new|o|open|q|quit|r|read|s|set|tc|tcommit|tre|trestart|tro|trollback|ts|tstart|u|use|v|view|w|write|x|xecute)\b/i,null],["lit",/^[+-]?(?:\.\d+|\d+(?:\.\d*)?)(?:e[+-]?\d+)?/i],["pln",/^[a-z][^\W_]*/i],["pun",/^[^\w\t\n\r"$%;^\xa0]|_/]]),["mumps"]);
3 |
--------------------------------------------------------------------------------
/guide/cmd/imports/functions/_oa-hyperlink.scss:
--------------------------------------------------------------------------------
1 | /**
2 | * @author OA Wu
3 | * @copyright Copyright (c) 2016 OA Wu Design
4 | */
5 |
6 | @mixin a($underLineHeight: 0, $d4UnderLine: false, $color: rgba(42, 90, 149, 0.7), $hoverColor: rgba(12, 65, 109, .85)) {
7 | display: inline-block;
8 |
9 | color: $color;
10 | font-weight: normal;
11 | text-decoration: none;
12 | padding: 0 2px;
13 | padding-bottom: $underLineHeight;
14 | @include transition(all .3s);
15 |
16 | @if($underLineHeight > 0) {
17 | @if($d4UnderLine) {
18 | border-bottom: $underLineHeight solid $color;
19 | }
20 | @else {
21 | border-bottom: $underLineHeight solid transparent;
22 | }
23 | }
24 | &.active, &:hover {
25 | color: $hoverColor;
26 |
27 | @if($underLineHeight > 0) {
28 | border-bottom: $underLineHeight solid $hoverColor;
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/guide/js/prettify/lang-scala.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["str",/^"(?:""(?:""?(?!")|[^"\\]|\\.)*"{0,3}|(?:[^\n\r"\\]|\\.)*"?)/,null,'"'],["lit",/^`(?:[^\n\r\\`]|\\.)*`?/,null,"`"],["pun",/^[!#%&(--:-@[-^{-~]+/,null,"!#%&()*+,-:;<=>?@[\\]^{|}~"]],[["str",/^'(?:[^\n\r'\\]|\\(?:'|[^\n\r']+))'/],["lit",/^'[$A-Z_a-z][\w$]*(?![\w$'])/],["kwd",/^(?:abstract|case|catch|class|def|do|else|extends|final|finally|for|forSome|if|implicit|import|lazy|match|new|object|override|package|private|protected|requires|return|sealed|super|throw|trait|try|type|val|var|while|with|yield)\b/],
2 | ["lit",/^(?:true|false|null|this)\b/],["lit",/^(?:0(?:[0-7]+|x[\da-f]+)l?|(?:0|[1-9]\d*)(?:(?:\.\d+)?(?:e[+-]?\d+)?f?|l?)|\\.\d+(?:e[+-]?\d+)?f?)/i],["typ",/^[$_]*[A-Z][\d$A-Z_]*[a-z][\w$]*/],["pln",/^[$A-Z_a-z][\w$]*/],["com",/^\/(?:\/.*|\*(?:\/|\**[^*/])*(?:\*+\/?)?)/],["pun",/^(?:\.+|\/)/]]),["scala"]);
3 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/Limit.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/limit-filter.html
10 | */
11 | class Elastica_Filter_Limit extends Elastica_Filter_Abstract
12 | {
13 | /**
14 | * Construct limit filter
15 | *
16 | * @param int $limit Limit
17 | * @return Elastica_Filter_Limit
18 | */
19 | public function __construct($limit)
20 | {
21 | $this->setLimit($limit);
22 | }
23 |
24 | /**
25 | * Set the limit
26 | *
27 | * @param int $limit Limit
28 | * @return Elastica_Filter_Limit
29 | */
30 | public function setLimit($limit)
31 | {
32 | return $this->setParam('value', (int) $limit);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/demo/Elastica/Exception/Response.php:
--------------------------------------------------------------------------------
1 |
8 | */
9 | class Elastica_Exception_Response extends Elastica_Exception_Abstract
10 | {
11 | /**
12 | * Response
13 | *
14 | * @var Elastica_Response Response object
15 | */
16 | protected $_response = null;
17 |
18 | /**
19 | * Construct Exception
20 | *
21 | * @param Elastica_Response $response
22 | */
23 | public function __construct(Elastica_Response $response)
24 | {
25 | $this->_response = $response;
26 | parent::__construct($response->getError());
27 | }
28 |
29 | /**
30 | * Returns reponsce object
31 | *
32 | * @return Elastica_Response Response object
33 | */
34 | public function getResponse()
35 | {
36 | return $this->_response;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/Not.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/not-filter.html
10 | */
11 | class Elastica_Filter_Not extends Elastica_Filter_Abstract
12 | {
13 | /**
14 | * Creates Not filter query
15 | *
16 | * @param Elastica_Filter_Abstract $filter Filter object
17 | */
18 | public function __construct(Elastica_Filter_Abstract $filter)
19 | {
20 | $this->setFilter($filter);
21 | }
22 |
23 | /**
24 | * Set filter
25 | *
26 | * @param Elastica_Filter_Abstract $filter
27 | * @return Elastica_Filter_Not
28 | */
29 | public function setFilter(Elastica_Filter_Abstract $filter)
30 | {
31 | return $this->setParam('filter', $filter->toArray());
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-dart.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"]],[["com",/^#!.*/],["kwd",/^\b(?:import|library|part of|part|as|show|hide)\b/i],["com",/^\/\/.*/],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["kwd",/^\b(?:class|interface)\b/i],["kwd",/^\b(?:assert|break|case|catch|continue|default|do|else|finally|for|if|in|is|new|return|super|switch|this|throw|try|while)\b/i],["kwd",/^\b(?:abstract|const|extends|factory|final|get|implements|native|operator|set|static|typedef|var)\b/i],
2 | ["typ",/^\b(?:bool|double|dynamic|int|num|object|string|void)\b/i],["kwd",/^\b(?:false|null|true)\b/i],["str",/^r?'''[\S\s]*?[^\\]'''/],["str",/^r?"""[\S\s]*?[^\\]"""/],["str",/^r?'('|[^\n\f\r]*?[^\\]')/],["str",/^r?"("|[^\n\f\r]*?[^\\]")/],["pln",/^[$_a-z]\w*/i],["pun",/^[!%&*+/:<-?^|~-]/],["lit",/^\b0x[\da-f]+/i],["lit",/^\b\d+(?:\.\d*)?(?:e[+-]?\d+)?/i],["lit",/^\b\.\d+(?:e[+-]?\d+)?/i],["pun",/^[(),.;[\]{}]/]]),
3 | ["dart"]);
4 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-apollo.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([["com",/^#[^\n\r]*/,null,"#"],["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,null,'"']],[["kwd",/^(?:ADS|AD|AUG|BZF|BZMF|CAE|CAF|CA|CCS|COM|CS|DAS|DCA|DCOM|DCS|DDOUBL|DIM|DOUBLE|DTCB|DTCF|DV|DXCH|EDRUPT|EXTEND|INCR|INDEX|NDX|INHINT|LXCH|MASK|MSK|MP|MSU|NOOP|OVSK|QXCH|RAND|READ|RELINT|RESUME|RETURN|ROR|RXOR|SQUARE|SU|TCR|TCAA|OVSK|TCF|TC|TS|WAND|WOR|WRITE|XCH|XLQ|XXALQ|ZL|ZQ|ADD|ADZ|SUB|SUZ|MPY|MPR|MPZ|DVP|COM|ABS|CLA|CLZ|LDQ|STO|STQ|ALS|LLS|LRS|TRA|TSQ|TMI|TOV|AXT|TIX|DLY|INP|OUT)\s/,
2 | null],["typ",/^(?:-?GENADR|=MINUS|2BCADR|VN|BOF|MM|-?2CADR|-?[1-6]DNADR|ADRES|BBCON|[ES]?BANK=?|BLOCK|BNKSUM|E?CADR|COUNT\*?|2?DEC\*?|-?DNCHAN|-?DNPTR|EQUALS|ERASE|MEMORY|2?OCT|REMADR|SETLOC|SUBRO|ORG|BSS|BES|SYN|EQU|DEFINE|END)\s/,null],["lit",/^'(?:-*(?:\w|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[!-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["apollo","agc","aea"]);
3 |
--------------------------------------------------------------------------------
/guide/cmd/imports/_oa-config.scss:
--------------------------------------------------------------------------------
1 | /**
2 | * @author OA Wu
3 | * @copyright Copyright (c) 2015 OA Wu Design
4 | */
5 | $mainWidth: 1400px !global;
6 | $mediaMobileWidth: 512px !global;
7 | $mediaTabletWidth: 960px !global;
8 |
9 | $mainBackgroundColor: rgba(255, 255, 255, 1) !global;
10 | $mainBackgroundImage: image-url('bg/grunge.png', false, false) !global;
11 |
12 | $btns: (
13 | 'red': (244, 67, 54),
14 | 'pink': (233, 30, 99),
15 | 'orange': (255, 152, 0),
16 | 'deep-orange': (255, 87, 34),
17 | 'yellow': (255, 235, 59),
18 | 'amber': (255, 193, 7),
19 | 'light-green': (139, 195, 74),
20 | 'green': (76, 175, 80),
21 | 'lime': (205, 220, 57),
22 | 'teal': (0, 150, 136),
23 | 'blue': (33, 150, 243),
24 | 'light-blue': (3, 169, 244),
25 | 'cyan': (0, 188, 212),
26 | 'indigo': (63, 81, 181),
27 | 'purple': (156, 39, 176),
28 | 'deep-purple': (103, 58, 183),
29 | 'brown': (121, 85, 72),
30 | 'gray': (158, 158, 158),
31 | 'blue-gray': (96, 125, 139),
32 | 'white': (200, 200, 200)
33 | ) !global;
--------------------------------------------------------------------------------
/guide/font/icomoon/icomoon/demo-files/demo.js:
--------------------------------------------------------------------------------
1 | if (!('boxShadow' in document.body.style)) {
2 | document.body.setAttribute('class', 'noBoxShadow');
3 | }
4 |
5 | document.body.addEventListener("click", function(e) {
6 | var target = e.target;
7 | if (target.tagName === "INPUT" &&
8 | target.getAttribute('class').indexOf('liga') === -1) {
9 | target.select();
10 | }
11 | });
12 |
13 | (function() {
14 | var fontSize = document.getElementById('fontSize'),
15 | testDrive = document.getElementById('testDrive'),
16 | testText = document.getElementById('testText');
17 | function updateTest() {
18 | testDrive.innerHTML = testText.value || String.fromCharCode(160);
19 | if (window.icomoonLiga) {
20 | window.icomoonLiga(testDrive);
21 | }
22 | }
23 | function updateSize() {
24 | testDrive.style.fontSize = fontSize.value + 'px';
25 | }
26 | fontSize.addEventListener('change', updateSize, false);
27 | testText.addEventListener('input', updateTest, false);
28 | testText.addEventListener('change', updateTest, false);
29 | updateSize();
30 | }());
31 |
--------------------------------------------------------------------------------
/guide/cmd/imports/functions/_oa-alert.scss:
--------------------------------------------------------------------------------
1 | /**
2 | * @author OA Wu
3 | * @copyright Copyright (c) 2016 OA Wu Design
4 | */
5 |
6 | @mixin alert ($type: 'danger', $shadow: true) {
7 | padding: 5px 10px;
8 | @include border-radius(4px);
9 |
10 | @if $shadow == true {
11 | @include box-shadow(0 2px 3px rgba(0,0,0,.175));
12 | }
13 | @if $type == 'success' {
14 | color: rgba(60, 118, 61, 1);
15 | background-color: rgba(223, 240, 216, 1);
16 | border: 1px solid rgba(214, 233, 198, 1);
17 | } @else if $type == 'info' {
18 | color: rgba(49, 112, 143, 1);
19 | background-color: rgba(217, 237, 247, 1);
20 | border: 1px solid rgba(188, 232, 241, 1);
21 |
22 | } @else if $type == 'warning' {
23 | color: rgba(138, 109, 59, 1);
24 | background-color: rgba(252, 248, 227, 1);
25 | border: 1px solid rgba(250, 235, 204, 1);
26 |
27 | } @else if $type == 'danger' {
28 | color: rgba(169, 68, 66, 1);
29 | background-color: rgba(242, 222, 222, 1);
30 | border: 1px solid rgba(169, 68, 66, .5);
31 | }
32 | }
--------------------------------------------------------------------------------
/guide/js/prettify/lang-ml.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["com",/^#(?:if[\t\n\r \xa0]+(?:[$_a-z][\w']*|``[^\t\n\r`]*(?:``|$))|else|endif|light)/i,null,"#"],["str",/^(?:"(?:[^"\\]|\\[\S\s])*(?:"|$)|'(?:[^'\\]|\\[\S\s])(?:'|$))/,null,"\"'"]],[["com",/^(?:\/\/[^\n\r]*|\(\*[\S\s]*?\*\))/],["kwd",/^(?:abstract|and|as|assert|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|if|in|inherit|inline|interface|internal|lazy|let|match|member|module|mutable|namespace|new|null|of|open|or|override|private|public|rec|return|static|struct|then|to|true|try|type|upcast|use|val|void|when|while|with|yield|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|global|include|method|mixin|object|parallel|process|protected|pure|sealed|trait|virtual|volatile)\b/],
2 | ["lit",/^[+-]?(?:0x[\da-f]+|(?:\.\d+|\d+(?:\.\d*)?)(?:e[+-]?\d+)?)/i],["pln",/^(?:[_a-z][\w']*[!#?]?|``[^\t\n\r`]*(?:``|$))/i],["pun",/^[^\w\t\n\r "'\xa0]+/]]),["fs","ml"]);
3 |
--------------------------------------------------------------------------------
/guide/cmd/imports/functions/_oa-input.scss:
--------------------------------------------------------------------------------
1 | /**
2 | * @author OA Wu
3 | * @copyright Copyright (c) 2016 OA Wu Design
4 | */
5 |
6 | @mixin input () {
7 | width: 250px;
8 | padding: 5px;
9 | border: 1px solid rgba(39, 40, 34, .25);
10 | font-size: 16px;
11 | color: rgba(50, 50, 50, 0.7);
12 |
13 | @include border-radius (2px);
14 | @include transition(all .3s);
15 |
16 | &[readonly] {
17 | background-color: rgba(240, 240, 240, 1);
18 |
19 | &:focus {
20 | outline: 0;
21 | border: 1px solid rgba(39, 40, 34, .25);
22 | @include box-shadow(none);
23 | }
24 | }
25 | &:focus {
26 | outline: 0;
27 | border: 1px solid rgba(102, 175, 233, 1);
28 | @include box-shadow(inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6));
29 | }
30 | &[type="file"] {
31 | font-size: 14px;
32 | }
33 | }
34 | @mixin input-error () {
35 | border-color: #a94442;
36 | box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
37 |
38 | &:focus {
39 | border-color: #843534;
40 | box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #ce8483;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/Wildcard.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/wildcard-query.html
10 | */
11 | class Elastica_Query_Wildcard extends Elastica_Query_Abstract
12 | {
13 | /**
14 | * Construct wildcard query
15 | *
16 | * @param string $key OPTIONAL Wildcard key
17 | * @param string $value OPTIONAL Wildcard value
18 | * @param float $boost OPTIONAL Boost value (default = 1)
19 | */
20 | public function __construct($key = '', $value = null, $boost = 1.0)
21 | {
22 | if (!empty($key)) {
23 | $this->setValue($key, $value, $boost);
24 | }
25 | }
26 |
27 | /**
28 | * Sets the query expression for a key with its boost value
29 | *
30 | * @param string $key
31 | * @param string $value
32 | * @param float $boost
33 | */
34 | public function setValue($key, $value, $boost = 1.0)
35 | {
36 | $this->setParam($key, array('value' => $value, 'boost' => $boost));
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/demo/Elastica/Facet/DateHistogram.php:
--------------------------------------------------------------------------------
1 |
8 | * @link http://www.elasticsearch.org/guide/reference/api/search/facets/date-histogram-facet.html
9 | * @link https://github.com/elasticsearch/elasticsearch/issues/591
10 | */
11 | class Elastica_Facet_DateHistogram extends Elastica_Facet_Histogram
12 | {
13 | /**
14 | * Set the time_zone parameter
15 | *
16 | * @param string $tzOffset
17 | * @return void
18 | */
19 | public function setTimezone($tzOffset)
20 | {
21 | return $this->setParam('time_zone', $tzOffset);
22 | }
23 |
24 | /**
25 | * Creates the full facet definition, which includes the basic
26 | * facet definition of the parent.
27 | *
28 | * @see Elastica_Facet_Abstract::toArray()
29 | * @throws Elastica_Exception_Invalid When the right fields haven't been set.
30 | * @return array
31 | */
32 | public function toArray()
33 | {
34 | /**
35 | * Set the range in the abstract as param.
36 | */
37 | $this->_setFacetParam('date_histogram', $this->_params);
38 |
39 | return $this->_facet;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/Nested.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/nested-query.html
10 | */
11 | class Elastica_Query_Nested extends Elastica_Query_Abstract
12 | {
13 | /**
14 | * Adds field to mlt query
15 | *
16 | * @param string $path Nested object path
17 | * @return Elastica_Query_Nested
18 | */
19 | public function setPath($path)
20 | {
21 | return $this->setParam('path', $path);
22 | }
23 |
24 | /**
25 | * Sets nested query
26 | *
27 | * @param Elastica_Query_Abstract $query
28 | * @return Elastica_Query_Nested
29 | */
30 | public function setQuery(Elastica_Query_Abstract $query)
31 | {
32 | return $this->setParam('query', $query->toArray());
33 | }
34 |
35 | /**
36 | * Set score method
37 | *
38 | * @param string $scoreMode Options: avg, total, max and none.
39 | * @return Elastica_Query_Nested
40 | */
41 | public function setScoreMode($scoreMode)
42 | {
43 | return $this->setParam('score_mode', $scoreMode);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/Array.php:
--------------------------------------------------------------------------------
1 |
10 | */
11 | class Elastica_Query_Array extends Elastica_Query_Abstract
12 | {
13 | /**
14 | * Query
15 | *
16 | * @var array Query
17 | */
18 | protected $_query = array();
19 |
20 | /**
21 | * Constructs a query based on an array
22 | *
23 | * @param array $query Query array
24 | */
25 | public function __construct(array $query)
26 | {
27 | $this->setQuery($query);
28 | }
29 |
30 | /**
31 | * Sets new query array
32 | *
33 | * @param array $query Query array
34 | * @return Elastica_Query_Array Current object
35 | */
36 | public function setQuery(array $query)
37 | {
38 | $this->_query = $query;
39 |
40 | return $this;
41 | }
42 |
43 | /**
44 | * Converts query to array
45 | *
46 | * @return array Query array
47 | * @see Elastica_Query_Abstract::toArray()
48 | */
49 | public function toArray()
50 | {
51 | return $this->_query;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/Nested.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter.html
10 | */
11 | class Elastica_Filter_Nested extends Elastica_Filter_Abstract
12 | {
13 | /**
14 | * Adds field to mlt filter
15 | *
16 | * @param string $path Nested object path
17 | * @return Elastica_Filter_Nested
18 | */
19 | public function setPath($path)
20 | {
21 | return $this->setParam('path', $path);
22 | }
23 |
24 | /**
25 | * Sets nested query
26 | *
27 | * @param Elastica_Query_Abstract $query
28 | * @return Elastica_Filter_Nested
29 | */
30 | public function setQuery(Elastica_Query_Abstract $query)
31 | {
32 | return $this->setParam('query', $query->toArray());
33 | }
34 |
35 | /**
36 | * Set score mode
37 | *
38 | * @param string $scoreMode Options: avg, total, max and none.
39 | * @return Elastica_Filter_Nested
40 | */
41 | public function setScoreMode($scoreMode)
42 | {
43 | return $this->setParam('score_mode', $scoreMode);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/demo/Elastica/Searchable.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 | interface Elastica_Searchable
11 | {
12 | /**
13 | * Searches results for a query
14 | *
15 | * TODO: Improve sample code
16 | * {
17 | * "from" : 0,
18 | * "size" : 10,
19 | * "sort" : {
20 | * "postDate" : {"reverse" : true},
21 | * "user" : { },
22 | * "_score" : { }
23 | * },
24 | * "query" : {
25 | * "term" : { "user" : "kimchy" }
26 | * }
27 | * }
28 | *
29 | * @param string|array|Elastica_Query $query Array with all query data inside or a Elastica_Query object
30 | * @return Elastica_ResultSet ResultSet with all results inside
31 | */
32 | public function search($query);
33 |
34 | /**
35 | * Counts results for a query
36 | *
37 | * If no query is set, matchall query is created
38 | *
39 | * @param string|array|Elastica_Query $query Array with all query data inside or a Elastica_Query object
40 | * @return int number of documents matching the query
41 | */
42 | public function count($query = '');
43 | }
44 |
--------------------------------------------------------------------------------
/guide/cmd/config.rb:
--------------------------------------------------------------------------------
1 | require 'compass/import-once/activate'
2 | # Require any additional compass plugins here.
3 |
4 | # Set this to the root of your project when deployed:
5 |
6 | http_path = "/OA-ElasticaSearch/guide"
7 |
8 | fonts_dir = "font"
9 | fonts_path = "../font"
10 |
11 | images_dir = "img"
12 | images_path = "../img"
13 |
14 | css_dir = "../css"
15 | sass_dir = "../scss"
16 |
17 | add_import_path = "./imports"
18 | additional_import_paths = ["./imports"]
19 |
20 | # images_dir = "images"
21 | # javascripts_dir = "javascripts"
22 |
23 | # You can select your preferred output style here (can be overridden via the command line):
24 | # output_style = :expanded or :nested or :compact or :compressed
25 | # output_style = :expanded
26 | output_style = :compressed
27 |
28 | # To enable relative paths to assets via compass helper functions. Uncomment:
29 | # relative_assets = true
30 |
31 | # To disable debugging comments that display the original location of your selectors. Uncomment:
32 | # line_comments = false
33 | line_comments = false
34 |
35 |
36 | # If you prefer the indented syntax, you might want to regenerate this
37 | # project again passing --syntax sass, or you can uncomment this:
38 | # preferred_syntax = :sass
39 | # and then run:
40 | # sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass
41 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/Term.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/term-filter.html
10 | */
11 | class Elastica_Filter_Term extends Elastica_Filter_Abstract
12 | {
13 | /**
14 | * Construct term filter
15 | *
16 | * @param array $term Term array
17 | */
18 | public function __construct(array $term = array())
19 | {
20 | $this->setRawTerm($term);
21 | }
22 |
23 | /**
24 | * Sets/overwrites key and term directly
25 | *
26 | * @param array $term Key value pair
27 | * @return Elastica_Filter_Term Filter object
28 | */
29 | public function setRawTerm(array $term)
30 | {
31 | return $this->setParams($term);
32 | }
33 |
34 | /**
35 | * Adds a term to the term query
36 | *
37 | * @param string $key Key to query
38 | * @param string|array $value Values(s) for the query. Boost can be set with array
39 | * @return Elastica_Filter_Term Filter object
40 | */
41 | public function setTerm($key, $value)
42 | {
43 | return $this->setRawTerm(array($key => $value));
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/CustomScore.php:
--------------------------------------------------------------------------------
1 |
10 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/custom-score-query.html
11 | */
12 | class Elastica_Query_CustomScore extends Elastica_Query_Abstract
13 | {
14 | /**
15 | * Sets query object
16 | *
17 | * @param string|Elastica_Query|Elastica_Query_Abstract $query
18 | * @return Elastica_Query_CustomScore
19 | */
20 | public function setQuery($query)
21 | {
22 | $query = Elastica_Query::create($query);
23 | $data = $query->toArray();
24 |
25 | return $this->setParam('query', $data['query']);
26 | }
27 |
28 | /**
29 | * Set script
30 | *
31 | * @param string $script
32 | * @return Elastica_Query_CustomScore
33 | */
34 | public function setScript($script)
35 | {
36 | return $this->setParam('script', $script);
37 | }
38 |
39 | /**
40 | * Add params
41 | *
42 | * @param array $params
43 | * @return Elastica_Query_CustomScore
44 | */
45 | public function addParams(array $params)
46 | {
47 | $this->setParam('params', $params);
48 |
49 | return $this;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-n.js:
--------------------------------------------------------------------------------
1 | var a=null;
2 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:'(?:[^\n\r'\\]|\\.)*'|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,a,'"'],["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,a,"#"],["pln",/^\s+/,a," \r\n\t\u00a0"]],[["str",/^@"(?:[^"]|"")*(?:"|$)/,a],["str",/^<#[^#>]*(?:#>|$)/,a],["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,a],["com",/^\/\/[^\n\r]*/,a],["com",/^\/\*[\S\s]*?(?:\*\/|$)/,
3 | a],["kwd",/^(?:abstract|and|as|base|catch|class|def|delegate|enum|event|extern|false|finally|fun|implements|interface|internal|is|macro|match|matches|module|mutable|namespace|new|null|out|override|params|partial|private|protected|public|ref|sealed|static|struct|syntax|this|throw|true|try|type|typeof|using|variant|virtual|volatile|when|where|with|assert|assert2|async|break|checked|continue|do|else|ensures|for|foreach|if|late|lock|new|nolate|otherwise|regexp|repeat|requires|return|surroundwith|unchecked|unless|using|while|yield)\b/,
4 | a],["typ",/^(?:array|bool|byte|char|decimal|double|float|int|list|long|object|sbyte|short|string|ulong|uint|ufloat|ulong|ushort|void)\b/,a],["lit",/^@[$_a-z][\w$@]*/i,a],["typ",/^@[A-Z]+[a-z][\w$@]*/,a],["pln",/^'?[$_a-z][\w$@]*/i,a],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,a,"0123456789"],["pun",/^.[^\s\w"-$'./@`]*/,a]]),["n","nemerle"]);
5 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/GeoPolygon.php:
--------------------------------------------------------------------------------
1 |
10 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/geo-polygon-filter.html
11 | */
12 | class Elastica_Filter_GeoPolygon extends Elastica_Filter_Abstract
13 | {
14 | /**
15 | * Key
16 | *
17 | * @var string Key
18 | */
19 | protected $_key = '';
20 |
21 | /**
22 | * Points making up polygon
23 | *
24 | * @var array Points making up polygon
25 | */
26 | protected $_points = array();
27 |
28 | /**
29 | * Construct polygon filter
30 | *
31 | * @param string $key Key
32 | * @param array $points Points making up polygon
33 | */
34 | public function __construct($key, array $points)
35 | {
36 | $this->_key = $key;
37 | $this->_points = $points;
38 | }
39 |
40 | /**
41 | * Converts filter to array
42 | *
43 | * @see Elastica_Filter_Abstract::toArray()
44 | * @return array
45 | */
46 | public function toArray()
47 | {
48 | return array(
49 | 'geo_polygon' => array(
50 | $this->_key => array(
51 | 'points' => $this->_points
52 | ),
53 | )
54 | );
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/guide/cmd/gulpfile.js:
--------------------------------------------------------------------------------
1 | var gulp = require ('gulp'),
2 | livereload = require('gulp-livereload'),
3 | uglifyJS = require ('gulp-uglify'),
4 | htmlmin = require('gulp-html-minifier'),
5 | del = require('del');
6 |
7 | // ===================================================
8 |
9 | gulp.task ('default', function () {
10 |
11 | livereload.listen ();
12 |
13 | ['./root/*.html', './root/css/**/*.css', './root/js/**/*.js'].forEach (function (t) {
14 | gulp.watch (t).on ('change', function () {
15 | gulp.run ('reload');
16 | });
17 | });
18 | });
19 | gulp.task ('reload', function () {
20 | livereload.changed ();
21 | console.info ('\n== ReLoad Browser! ================================================\n');
22 | });
23 |
24 | // ===================================================
25 |
26 | gulp.task ('minify', function () {
27 | gulp.run ('js-uglify');
28 | gulp.run ('minify-html');
29 | });
30 | gulp.task ('js-uglify', function () {
31 | gulp.src ('./root/js/**/*.js')
32 | .pipe (uglifyJS ())
33 | .pipe (gulp.dest ('./root/js/'));
34 | });
35 | gulp.task ('minify-html', function () {
36 | gulp.src ('./root/*.html')
37 | .pipe (htmlmin ({collapseWhitespace: true}))
38 | .pipe (gulp.dest ('./root/'));
39 | });
40 |
41 | // ===================================================
42 |
43 | gulp.task ('gh-pages', function () {
44 | del (['./root']);
45 | });
--------------------------------------------------------------------------------
/guide/css/prettify/prettify.css:
--------------------------------------------------------------------------------
1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print, projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}li.L0,li.L2,li.L4,li.L6,li.L8{background:#ddd}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8,li.L9{list-style-type:decimal !important}.prettyprint{margin-bottom:0px !important;text-align:left}.prettyprint .filepath{background-color:#eee;border-bottom:1px solid #777;font-size:12px;text-align:right;font-style:italic;color:#888}.prettyprint .filepath:before{content:"File : ";float:left;color:#555}.prettyprint ol.linenums li{border-left:1px solid rgba(39,40,34,0.3);word-break:break-all;padding:0;padding-left:4px;*zoom:1}.prettyprint ol.linenums li:after{display:table;content:"";line-height:0;clear:both}.prettyprint ol.linenums li span{float:left;display:inline-block;margin-top:-12px;margin-bottom:5px}.prettyprint ol.linenums li:last-child{display:none}
2 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/ConstantScore.php:
--------------------------------------------------------------------------------
1 |
10 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/constant-score-query.html
11 | */
12 | class Elastica_Query_ConstantScore extends Elastica_Query_Abstract
13 | {
14 | /**
15 | * Construct constant score query
16 | *
17 | * @param null|Elastica_Filter_Abstract|array $filter
18 | */
19 | public function __construct($filter = null)
20 | {
21 | if (!is_null($filter)) {
22 | $this->setFilter($filter);
23 | }
24 | }
25 |
26 | /**
27 | * Set filter
28 | *
29 | * @param array|Elastica_Filter_Abstract $filter
30 | * @return Elastica_Query_ConstantScore Query object
31 | */
32 | public function setFilter($filter)
33 | {
34 | if ($filter instanceof Elastica_Filter_Abstract) {
35 | $filter = $filter->toArray();
36 | }
37 |
38 | return $this->setParam('filter', $filter);
39 | }
40 |
41 | /**
42 | * Set boost
43 | *
44 | * @param float $boost
45 | * @return Elastica_Query_ConstantScore
46 | */
47 | public function setBoost($boost)
48 | {
49 | return $this->setParam('boost', $boost);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-vhdl.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"]],[["str",/^(?:[box]?"(?:[^"]|"")*"|'.')/i],["com",/^--[^\n\r]*/],["kwd",/^(?:abs|access|after|alias|all|and|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|constant|disconnect|downto|else|elsif|end|entity|exit|file|for|function|generate|generic|group|guarded|if|impure|in|inertial|inout|is|label|library|linkage|literal|loop|map|mod|nand|new|next|nor|not|null|of|on|open|or|others|out|package|port|postponed|procedure|process|pure|range|record|register|reject|rem|report|return|rol|ror|select|severity|shared|signal|sla|sll|sra|srl|subtype|then|to|transport|type|unaffected|units|until|use|variable|wait|when|while|with|xnor|xor)(?=[^\w-]|$)/i,
2 | null],["typ",/^(?:bit|bit_vector|character|boolean|integer|real|time|string|severity_level|positive|natural|signed|unsigned|line|text|std_u?logic(?:_vector)?)(?=[^\w-]|$)/i,null],["typ",/^'(?:active|ascending|base|delayed|driving|driving_value|event|high|image|instance_name|last_active|last_event|last_value|left|leftof|length|low|path_name|pos|pred|quiet|range|reverse_range|right|rightof|simple_name|stable|succ|transaction|val|value)(?=[^\w-]|$)/i,null],["lit",/^\d+(?:_\d+)*(?:#[\w.\\]+#(?:[+-]?\d+(?:_\d+)*)?|(?:\.\d+(?:_\d+)*)?(?:e[+-]?\d+(?:_\d+)*)?)/i],
3 | ["pln",/^(?:[a-z]\w*|\\[^\\]*\\)/i],["pun",/^[^\w\t\n\r "'\xa0][^\w\t\n\r "'\xa0-]*/]]),["vhdl","vhd"]);
4 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/Abstract.php:
--------------------------------------------------------------------------------
1 |
8 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/
9 | */
10 | abstract class Elastica_Filter_Abstract extends Elastica_Param
11 | {
12 | /**
13 | * Sets the filter cache
14 | *
15 | * @param boolean $cached Cached
16 | * @return Elastica_Filter_Abstract
17 | */
18 | public function setCached($cached = true)
19 | {
20 | return $this->setParam('_cache', (bool) $cached);
21 | }
22 |
23 | /**
24 | * Sets the filter cache key
25 | *
26 | * @param string $cacheKey Cache key
27 | * @return Elastica_Filter_Abstract
28 | */
29 | public function setCacheKey($cacheKey)
30 | {
31 | $cacheKey = (string) $cacheKey;
32 |
33 | if (empty($cacheKey)) {
34 | throw new Elastica_Exception_Invalid('Invalid parameter. Has to be a non empty string');
35 | }
36 |
37 | return $this->setParam('_cache_key', (string) $cacheKey);
38 | }
39 |
40 | /**
41 | * Sets the filter name
42 | *
43 | * @param string $name Name
44 | * @return Elastica_Filter_Abstract
45 | */
46 | public function setName($name)
47 | {
48 | return $this->setParam('_name', $name);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/demo/Elastica/Transport/Abstract.php:
--------------------------------------------------------------------------------
1 |
8 | */
9 | abstract class Elastica_Transport_Abstract
10 | {
11 | /**
12 | * Path
13 | *
14 | * @var string path
15 | */
16 | protected $_path;
17 |
18 | /**
19 | * Method
20 | *
21 | * @var string method
22 | * @todo set default method?
23 | */
24 | protected $_method;
25 |
26 | /**
27 | * Data
28 | *
29 | * @var array Data
30 | */
31 | protected $_data;
32 |
33 | /**
34 | * Config
35 | *
36 | * @var array config
37 | */
38 | protected $_config;
39 |
40 | /**
41 | * Construc transport
42 | *
43 | * @param Elastica_Request $request Request object
44 | */
45 | public function __construct(Elastica_Request $request)
46 | {
47 | $this->_request = $request;
48 | }
49 |
50 | /**
51 | * Returns the request object
52 | *
53 | * @return Elastica_Request Request object
54 | */
55 | public function getRequest()
56 | {
57 | return $this->_request;
58 | }
59 |
60 | /**
61 | * Executes the transport request
62 | *
63 | * @param array $params Hostname, port, path, ...
64 | * @return Elastica_Response Response object
65 | */
66 | abstract public function exec(array $params);
67 | }
68 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/Type.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/type-filter.html
10 | */
11 | class Elastica_Filter_Type extends Elastica_Filter_Abstract
12 | {
13 | /**
14 | * Type
15 | *
16 | * @var Elastica_Type Type object
17 | */
18 | protected $_type = null;
19 |
20 | /**
21 | * Construct Type Filter
22 | *
23 | * @param string $typeName Type name
24 | * @return Elastica_Filter_Type
25 | */
26 | public function __construct($typeName = null)
27 | {
28 | if ($typeName) {
29 | $this->setType($typeName);
30 | }
31 | }
32 |
33 | /**
34 | * Ads a field with arguments to the range query
35 | *
36 | * @param string $typeName Type name
37 | * @return Elastica_Filter_Type current object
38 | */
39 | public function setType($typeName)
40 | {
41 | $this->_type = $typeName;
42 |
43 | return $this;
44 | }
45 |
46 | /**
47 | * Convert object to array
48 | *
49 | * @see Elastica_Filter_Abstract::toArray()
50 | * @return array Filter array
51 | */
52 | public function toArray()
53 | {
54 | return array(
55 | 'type' => array('value' => $this->_type)
56 | );
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-clj.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 Google Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | var a=null;
17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^[([{]+/,a,"([{"],["clo",/^[)\]}]+/,a,")]}"],["com",/^;[^\n\r]*/,a,";"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \u00a0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["kwd",/^(?:def|if|do|let|quote|var|fn|loop|recur|throw|try|monitor-enter|monitor-exit|defmacro|defn|defn-|macroexpand|macroexpand-1|for|doseq|dosync|dotimes|and|or|when|not|assert|doto|proxy|defstruct|first|rest|cons|defprotocol|deftype|defrecord|reify|defmulti|defmethod|meta|with-meta|ns|in-ns|create-ns|import|intern|refer|alias|namespace|resolve|ref|deref|refset|new|set!|memfn|to-array|into-array|aset|gen-class|reduce|map|filter|find|nil?|empty?|hash-map|hash-set|vec|vector|seq|flatten|reverse|assoc|dissoc|list|list?|disj|get|union|difference|intersection|extend|extend-type|extend-protocol|prn)\b/,a],
18 | ["typ",/^:[\dA-Za-z-]+/]]),["clj"]);
19 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/HasChild.php:
--------------------------------------------------------------------------------
1 |
10 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/has-child-query.html
11 | */
12 | class Elastica_Query_HasChild extends Elastica_Query_Abstract
13 | {
14 | /**
15 | * Construct HasChild Query
16 | *
17 | * @param string|Elastica_Query $query Query string or a Elastica_Query object
18 | * @param string $type Parent document type
19 | */
20 | public function __construct($query, $type = null)
21 | {
22 | $this->setQuery($query);
23 | $this->setType($type);
24 | }
25 |
26 | /**
27 | * Sets query object
28 | *
29 | * @param string|Elastica_Query|Elastica_Query_Abstract $query
30 | * @return Elastica_Query_HasChild
31 | */
32 | public function setQuery($query)
33 | {
34 | $query = Elastica_Query::create($query);
35 | $data = $query->toArray();
36 |
37 | return $this->setParam('query', $data['query']);
38 | }
39 |
40 | /**
41 | * Set type of the parent document
42 | *
43 | * @param string $type Parent document type
44 | * @return Elastica_Query_HasChild Current object
45 | */
46 | public function setType($type)
47 | {
48 | return $this->setParam('type', $type);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/Term.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/term-query.html
10 | */
11 | class Elastica_Query_Term extends Elastica_Query_Abstract
12 | {
13 | /**
14 | * Constructs the Term query object
15 | *
16 | * @param array $term OPTIONAL Calls setTerm with the given $term array
17 | */
18 | public function __construct(array $term = array())
19 | {
20 | $this->setRawTerm($term);
21 | }
22 |
23 | /**
24 | * Set term can be used instead of addTerm if some more special
25 | * values for a term have to be set.
26 | *
27 | * @param array $term Term array
28 | * @return Elastica_Query_Term Current object
29 | */
30 | public function setRawTerm(array $term)
31 | {
32 | return $this->setParams($term);
33 | }
34 |
35 | /**
36 | * Adds a term to the term query
37 | *
38 | * @param string $key Key to query
39 | * @param string|array $value Values(s) for the query. Boost can be set with array
40 | * @param float $boost OPTIONAL Boost value (default = 1.0)
41 | * @return Elastica_Query_Term Current object
42 | */
43 | public function setTerm($key, $value, $boost = 1.0)
44 | {
45 | return $this->setRawTerm(array($key => array('value' => $value, 'boost' => $boost)));
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/Prefix.php:
--------------------------------------------------------------------------------
1 | setRawPrefix($prefix);
20 | }
21 |
22 | /**
23 | * setRawPrefix can be used instead of setPrefix if some more special
24 | * values for a prefix have to be set.
25 | *
26 | * @param array $prefix Prefix array
27 | * @return Elastica_Query_Prefix Current object
28 | */
29 | public function setRawPrefix(array $prefix)
30 | {
31 | return $this->setParams($prefix);
32 | }
33 |
34 | /**
35 | * Adds a prefix to the prefix query
36 | *
37 | * @param string $key Key to query
38 | * @param string|array $value Values(s) for the query. Boost can be set with array
39 | * @param float $boost OPTIONAL Boost value (default = 1.0)
40 | * @return Elastica_Query_Prefix Current object
41 | */
42 | public function setPrefix($key, $value, $boost = 1.0)
43 | {
44 | return $this->setRawPrefix(array($key => array('value' => $value, 'boost' => $boost)));
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/HasChild.php:
--------------------------------------------------------------------------------
1 |
10 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/has-child-filter.html
11 | */
12 | class Elastica_Filter_HasChild extends Elastica_Filter_Abstract
13 | {
14 | /**
15 | * Construct HasChild filter
16 | *
17 | * @param string|Elastica_Query $query Query string or a Elastica_Query object
18 | * @param string $type Parent document type
19 | */
20 | public function __construct($query, $type = null)
21 | {
22 | $this->setQuery($query);
23 | $this->setType($type);
24 | }
25 |
26 | /**
27 | * Sets query object
28 | *
29 | * @param string|Elastica_Query|Elastica_Query_Abstract $query
30 | * @return Elastica_Filter_HasChild Current object
31 | */
32 | public function setQuery($query)
33 | {
34 | $query = Elastica_Query::create($query);
35 | $data = $query->toArray();
36 |
37 | return $this->setParam('query', $data['query']);
38 | }
39 |
40 | /**
41 | * Set type of the parent document
42 | *
43 | * @param string $type Parent document type
44 | * @return Elastica_Filter_HasChild Current object
45 | */
46 | public function setType($type)
47 | {
48 | return $this->setParam('type', $type);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/TopChildren.php:
--------------------------------------------------------------------------------
1 |
10 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/top-children-query.html
11 | */
12 | class Elastica_Query_TopChildren extends Elastica_Query_Abstract
13 | {
14 | /**
15 | * Construct topChildren query
16 | *
17 | * @param string|Elastica_Query $query Query string or a Elastica_Query object
18 | * @param string $type Parent document type
19 | */
20 | public function __construct($query, $type = null)
21 | {
22 | $this->setQuery($query);
23 | $this->setType($type);
24 | }
25 |
26 | /**
27 | * Sets query object
28 | *
29 | * @param string|Elastica_Query|Elastica_Query_Abstract $query
30 | * @return Elastica_Query_TopChildren
31 | */
32 | public function setQuery($query)
33 | {
34 | $query = Elastica_Query::create($query);
35 | $data = $query->toArray();
36 |
37 | return $this->setParam('query', $data['query']);
38 | }
39 |
40 | /**
41 | * Set type of the parent document
42 | *
43 | * @param string $type Parent document type
44 | * @return Elastica_Query_TopChildren Current object
45 | */
46 | public function setType($type)
47 | {
48 | return $this->setParam('type', $type);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/demo/Elastica/ScriptFields.php:
--------------------------------------------------------------------------------
1 |
8 | * @link http://www.elasticsearch.org/guide/reference/api/search/script-fields.html
9 | */
10 | class Elastica_ScriptFields extends Elastica_Param
11 | {
12 | /**
13 | * @param array $scripts OPTIONAL
14 | */
15 | public function __construct(array $scripts = array())
16 | {
17 | if ($scripts) {
18 | $this->setScripts($scripts);
19 | }
20 | }
21 |
22 | /**
23 | * @param string $name Name of the Script field
24 | * @param Elastica_Script $script
25 | * @return Elastica_ScriptFields
26 | */
27 | public function addScript($name, Elastica_Script $script)
28 | {
29 | if (!is_string($name) || !strlen($name)) {
30 | throw new Elastica_Exception_Invalid('The name of a Script is required and must be a string');
31 | }
32 | $this->setParam($name, $script->toArray());
33 |
34 | return $this;
35 | }
36 |
37 | /**
38 | * @param array $script Associative array of string => Elastica_Script
39 | * @return Elastica_ScriptFields
40 | */
41 | public function setScripts(array $scripts)
42 | {
43 | $this->_params = array();
44 | foreach ($scripts as $name => $script) {
45 | $this->addScript($name, $script);
46 | }
47 |
48 | return $this;
49 | }
50 |
51 | public function toArray()
52 | {
53 | return $this->_params;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/Range.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/range-filter.html
10 | */
11 | class Elastica_Filter_Range extends Elastica_Filter_Abstract
12 | {
13 | /**
14 | * Fields
15 | *
16 | * @var array Fields
17 | */
18 | protected $_fields = array();
19 |
20 | /**
21 | * Construct range filter
22 | *
23 | * @param string $fieldName Field name
24 | * @param array $args Field arguments
25 | * @return Elastica_Filter_Range
26 | */
27 | public function __construct($fieldName = false, array $args = array())
28 | {
29 | if ($fieldName) {
30 | $this->addField($fieldName, $args);
31 | }
32 | }
33 |
34 | /**
35 | * Ads a field with arguments to the range query
36 | *
37 | * @param string $fieldName Field name
38 | * @param array $args Field arguments
39 | * @return Elastica_Filter_Range
40 | */
41 | public function addField($fieldName, array $args)
42 | {
43 | $this->_fields[$fieldName] = $args;
44 |
45 | return $this;
46 | }
47 |
48 | /**
49 | * Convers object to array
50 | *
51 | * @see Elastica_Filter_Abstract::toArray()
52 | * @return array Filter array
53 | */
54 | public function toArray()
55 | {
56 | $this->setParams($this->_fields);
57 |
58 | return parent::toArray();
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/GeoBoundingBox.php:
--------------------------------------------------------------------------------
1 |
10 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/geo-bounding-box-filter.html
11 | */
12 | class Elastica_Filter_GeoBoundingBox extends Elastica_Filter_Abstract
13 | {
14 | /**
15 | * Construct GeoBoundingBox filter
16 | *
17 | * @param string $key Key
18 | * @param array $coordinates Array with top left coordinate as first and bottom right coordinate as second element
19 | */
20 | public function __construct($key, array $coordinates)
21 | {
22 | $this->addCoordinates($key, $coordinates);
23 | }
24 |
25 | /**
26 | * Add coordinates
27 | *
28 | * @param string $key Key
29 | * @param array $coordinates Array with top left coordinate as first and bottom right coordinate as second element
30 | * @throws Elastica_Exception_Invalid If $coordinates doesn't have two elements
31 | * @return Elastica_Filter_GeoBoundingBox Current object
32 | */
33 | public function addCoordinates($key, array $coordinates)
34 | {
35 | if (!isset($coordinates[0]) || !isset($coordinates[1])) {
36 | throw new Elastica_Exception_Invalid('expected $coordinates to be an array with two elements');
37 | }
38 |
39 | $this->setParam($key, array(
40 | 'top_left' => $coordinates[0],
41 | 'bottom_right' => $coordinates[1]
42 | ));
43 |
44 | return $this;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/Abstract/Multi.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 | abstract class Elastica_Filter_Abstract_Multi extends Elastica_Filter_Abstract
11 | {
12 | /**
13 | * Filters
14 | * @var array
15 | */
16 | protected $_filters = array();
17 |
18 | /**
19 | * Add filter
20 | *
21 | * @param Elastica_Filter_Abstract $filter
22 | * @return Elastica_Filter_Abstract_Multi
23 | */
24 | public function addFilter(Elastica_Filter_Abstract $filter)
25 | {
26 | $this->_filters[] = $filter->toArray();
27 |
28 | return $this;
29 | }
30 |
31 | /**
32 | * Set filters
33 | *
34 | * @param array $filters
35 | * @return Elastica_Filter_Abstract_Multi
36 | */
37 | public function setFilters(array $filters)
38 | {
39 | $this->_filters = array();
40 |
41 | foreach ($filters as $filter) {
42 | $this->addFilter($filter);
43 | }
44 |
45 | return $this;
46 | }
47 |
48 | /**
49 | * @see Elastica_Param::toArray()
50 | */
51 | public function toArray()
52 | {
53 | $data = parent::toArray();
54 | $name = $this->_getBaseName();
55 | $filterData = $data[$name];
56 |
57 | if (empty($filterData)) {
58 | $filterData = $this->_filters;
59 | } else {
60 | $filterData['filters'] = $this->_filters;
61 | }
62 |
63 | $data[$name] = $filterData;
64 |
65 | return $data;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/demo/Elastica/Exception/BulkResponse.php:
--------------------------------------------------------------------------------
1 | _response = $response;
25 | parent::__construct('Error in one or more bulk request actions');
26 | }
27 |
28 | /**
29 | * Returns response object
30 | *
31 | * @return Elastica_Response Response object
32 | */
33 | public function getResponse()
34 | {
35 | return $this->_response;
36 | }
37 |
38 | /**
39 | * Returns array of failed actions
40 | *
41 | * @return array Array of failed actions
42 | */
43 | public function getFailures()
44 | {
45 | $data = $this->_response->getData();
46 | $errors = array();
47 |
48 | foreach ($data['items'] as $item) {
49 | $meta = reset($item);
50 | $action = key($item);
51 | if (isset($meta['error'])) {
52 | $error = array(
53 | 'action' => $action,
54 | );
55 | foreach ($meta as $key => $value) {
56 | $key = ltrim($key, '_');
57 | $error[$key] = $value;
58 | }
59 |
60 | $errors[] = $error;
61 | }
62 | }
63 |
64 | return $errors;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-vb.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0\u2028\u2029]+/,null,"\t\n\r \u00a0\u2028\u2029"],["str",/^(?:["\u201c\u201d](?:[^"\u201c\u201d]|["\u201c\u201d]{2})(?:["\u201c\u201d]c|$)|["\u201c\u201d](?:[^"\u201c\u201d]|["\u201c\u201d]{2})*(?:["\u201c\u201d]|$))/i,null,'"\u201c\u201d'],["com",/^['\u2018\u2019](?:_(?:\r\n?|[^\r]?)|[^\n\r_\u2028\u2029])*/,null,"'\u2018\u2019"]],[["kwd",/^(?:addhandler|addressof|alias|and|andalso|ansi|as|assembly|auto|boolean|byref|byte|byval|call|case|catch|cbool|cbyte|cchar|cdate|cdbl|cdec|char|cint|class|clng|cobj|const|cshort|csng|cstr|ctype|date|decimal|declare|default|delegate|dim|directcast|do|double|each|else|elseif|end|endif|enum|erase|error|event|exit|finally|for|friend|function|get|gettype|gosub|goto|handles|if|implements|imports|in|inherits|integer|interface|is|let|lib|like|long|loop|me|mod|module|mustinherit|mustoverride|mybase|myclass|namespace|new|next|not|notinheritable|notoverridable|object|on|option|optional|or|orelse|overloads|overridable|overrides|paramarray|preserve|private|property|protected|public|raiseevent|readonly|redim|removehandler|resume|return|select|set|shadows|shared|short|single|static|step|stop|string|structure|sub|synclock|then|throw|to|try|typeof|unicode|until|variant|wend|when|while|with|withevents|writeonly|xor|endif|gosub|let|variant|wend)\b/i,
2 | null],["com",/^rem\b.*/i],["lit",/^(?:true\b|false\b|nothing\b|\d+(?:e[+-]?\d+[dfr]?|[dfilrs])?|(?:&h[\da-f]+|&o[0-7]+)[ils]?|\d*\.\d+(?:e[+-]?\d+)?[dfr]?|#\s+(?:\d+[/-]\d+[/-]\d+(?:\s+\d+:\d+(?::\d+)?(\s*(?:am|pm))?)?|\d+:\d+(?::\d+)?(\s*(?:am|pm))?)\s+#)/i],["pln",/^(?:(?:[a-z]|_\w)\w*(?:\[[!#%&@]+])?|\[(?:[a-z]|_\w)\w*])/i],["pun",/^[^\w\t\n\r "'[\]\xa0\u2018\u2019\u201c\u201d\u2028\u2029]+/],["pun",/^(?:\[|])/]]),["vb","vbs"]);
3 |
--------------------------------------------------------------------------------
/guide/js/prettify/lang-sql.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["str",/^(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')/,null,"\"'"]],[["com",/^(?:--[^\n\r]*|\/\*[\S\s]*?(?:\*\/|$))/],["kwd",/^(?:add|all|alter|and|any|apply|as|asc|authorization|backup|begin|between|break|browse|bulk|by|cascade|case|check|checkpoint|close|clustered|coalesce|collate|column|commit|compute|connect|constraint|contains|containstable|continue|convert|create|cross|current|current_date|current_time|current_timestamp|current_user|cursor|database|dbcc|deallocate|declare|default|delete|deny|desc|disk|distinct|distributed|double|drop|dummy|dump|else|end|errlvl|escape|except|exec|execute|exists|exit|fetch|file|fillfactor|following|for|foreign|freetext|freetexttable|from|full|function|goto|grant|group|having|holdlock|identity|identitycol|identity_insert|if|in|index|inner|insert|intersect|into|is|join|key|kill|left|like|lineno|load|match|matched|merge|natural|national|nocheck|nonclustered|nocycle|not|null|nullif|of|off|offsets|on|open|opendatasource|openquery|openrowset|openxml|option|or|order|outer|over|partition|percent|pivot|plan|preceding|precision|primary|print|proc|procedure|public|raiserror|read|readtext|reconfigure|references|replication|restore|restrict|return|revoke|right|rollback|rowcount|rowguidcol|rows?|rule|save|schema|select|session_user|set|setuser|shutdown|some|start|statistics|system_user|table|textsize|then|to|top|tran|transaction|trigger|truncate|tsequal|unbounded|union|unique|unpivot|update|updatetext|use|user|using|values|varying|view|waitfor|when|where|while|with|within|writetext|xml)(?=[^\w-]|$)/i,
2 | null],["lit",/^[+-]?(?:0x[\da-f]+|(?:\.\d+|\d+(?:\.\d*)?)(?:e[+-]?\d+)?)/i],["pln",/^[_a-z][\w-]*/i],["pun",/^[^\w\t\n\r "'\xa0][^\w\t\n\r "'+\xa0-]*/]]),["sql"]);
3 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/Prefix.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/prefix-filter.html
10 | */
11 | class Elastica_Filter_Prefix extends Elastica_Filter_Abstract
12 | {
13 | /**
14 | * Holds the name of the field for the prefix.
15 | *
16 | * @var string
17 | */
18 | protected $_field = '';
19 |
20 | /**
21 | * Holds the prefix string.
22 | *
23 | * @var string
24 | */
25 | protected $_prefix = '';
26 |
27 | /**
28 | * Creates prefix filter
29 | *
30 | * @param string $field Field name
31 | * @param string $prefix Prefix string
32 | */
33 | public function __construct($field = '', $prefix = '')
34 | {
35 | $this->setField($field);
36 | $this->setPrefix($prefix);
37 | }
38 |
39 | /**
40 | * Sets the name of the prefix field.
41 | *
42 | * @param string $field Field name
43 | */
44 | public function setField($field)
45 | {
46 | $this->_field = $field;
47 |
48 | return $this;
49 | }
50 |
51 | /**
52 | * Sets the prefix string.
53 | *
54 | * @param string $prefix Prefix string
55 | */
56 | public function setPrefix($prefix)
57 | {
58 | $this->_prefix = $prefix;
59 |
60 | return $this;
61 | }
62 |
63 | /**
64 | * Convers object to an arrray
65 | *
66 | * @see Elastica_Filter_Abstract::toArray()
67 | * @return array data array
68 | */
69 | public function toArray()
70 | {
71 | $this->setParam($this->_field, $this->_prefix);
72 |
73 | return parent::toArray();
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/demo/Elastica/Facet/Statistical.php:
--------------------------------------------------------------------------------
1 |
8 | * @link http://www.elasticsearch.org/guide/reference/api/search/facets/statistical-facet.html
9 | */
10 | class Elastica_Facet_Statistical extends Elastica_Facet_Abstract
11 | {
12 | /**
13 | * Sets the field for the statistical query.
14 | *
15 | * @param string $field The field name for the statistical query.
16 | * @return Elastica_Facet_Statistical
17 | */
18 | public function setField($field)
19 | {
20 | return $this->setParam('field', $field);
21 | }
22 |
23 | /**
24 | * Sets multiple fields for the statistical query.
25 | *
26 | * @param array $fields Numerical array with the fields for the statistical query.
27 | * @return Elastica_Facet_Statistical
28 | */
29 | public function setFields(array $fields)
30 | {
31 | return $this->setParam('fields', $fields);
32 | }
33 |
34 | /**
35 | * Sets a script to calculate statistical information
36 | *
37 | * @param string $script The script to do calculations on the statistical values
38 | * @return Elastica_Facet_Statistical
39 | */
40 | public function setScript($script)
41 | {
42 | return $this->setParam('script', $script);
43 | }
44 |
45 | /**
46 | * Creates the full facet definition, which includes the basic
47 | * facet definition of the parent.
48 | *
49 | * @see Elastica_Facet_Abstract::toArray()
50 | * @return array
51 | */
52 | public function toArray()
53 | {
54 | $this->_setFacetParam('statistical', $this->_params);
55 |
56 | return parent::toArray();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/Script.php:
--------------------------------------------------------------------------------
1 |
10 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/script-filter.html
11 | */
12 | class Elastica_Filter_Script extends Elastica_Filter_Abstract
13 | {
14 | /**
15 | * Query object
16 | *
17 | * @var array|Elastica_Query_Abstract
18 | */
19 | protected $_query = null;
20 |
21 | /**
22 | * Construct script filter
23 | *
24 | * @param array|Elastica_Query_Abstract $query OPTIONAL Query object
25 | */
26 | public function __construct($query = null)
27 | {
28 | if (!is_null($query)) {
29 | $this->setQuery($query);
30 | }
31 | }
32 |
33 | /**
34 | * Sets query object
35 | *
36 | * @param array|Elastica_Query_Abstract $query
37 | * @return Elastica_Filter_Script
38 | * @throws Elastica_Exception_Invalid Invalid argument type
39 | */
40 | public function setQuery($query)
41 | {
42 | // TODO: check if should be renamed to setScript?
43 | if (!$query instanceof Elastica_Query_Abstract && !is_array($query)) {
44 | throw new Elastica_Exception_Invalid('expected an array or instance of Elastica_Query_Abstract');
45 | }
46 |
47 | if ($query instanceof Elastica_Query_Abstract) {
48 | $this->_query = $query->toArray();
49 | } else {
50 | $this->_query = $query;
51 | }
52 |
53 | return $this;
54 | }
55 |
56 | /**
57 | * ToArray
58 | *
59 | * @return array Script filter
60 | * @see Elastica_Filter_Abstract::toArray()
61 | */
62 | public function toArray()
63 | {
64 | return array(
65 | 'script' => (
66 | $this->_query
67 | ),
68 | );
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/demo/Elastica/Facet/TermsStats.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/api/search/facets/terms-stats-facet.html
10 | */
11 | class Elastica_Facet_TermsStats extends Elastica_Facet_Abstract
12 | {
13 |
14 | /**
15 | * Sets the key field for the query.
16 | *
17 | * @param string $keyField The key field name for the query.
18 | * @return Elastica_Facet_TermsStats
19 | */
20 | public function setKeyField( $keyField )
21 | {
22 | return $this->setParam( 'key_field', $keyField );
23 | }
24 |
25 | /**
26 | * Sets a script to calculate statistical information on a per term basis
27 | *
28 | * @param string $valueScript The script to do calculations on the statistical values
29 | * @return Elastica_Facet_TermsStats
30 | */
31 | public function setValueScript( $valueScript )
32 | {
33 | return $this->setParam( 'value_script', $valueScript );
34 | }
35 |
36 | /**
37 | * Sets a field to compute basic statistical results on
38 | *
39 | * @param string $valueField The field to compute statistical values for
40 | * @return Elastica_Facet_TermsStats
41 | */
42 | public function setValueField( $valueField )
43 | {
44 | return $this->setParam( 'value_field', $valueField );
45 | }
46 |
47 | /**
48 | * Creates the full facet definition, which includes the basic
49 | * facet definition of the parent.
50 | *
51 | * @see Elastica_Facet_Abstract::toArray()
52 | * @return array
53 | */
54 | public function toArray()
55 | {
56 | $this->_setFacetParam( 'terms_stats', $this->_params );
57 |
58 | return parent::toArray();
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/guide/font/icomoon/icomoon/style.css:
--------------------------------------------------------------------------------
1 | @font-face {
2 | font-family: 'icomoon';
3 | src:url('fonts/icomoon.eot?-dllii');
4 | src:url('fonts/icomoon.eot?#iefix-dllii') format('embedded-opentype'),
5 | url('fonts/icomoon.ttf?-dllii') format('truetype'),
6 | url('fonts/icomoon.woff?-dllii') format('woff'),
7 | url('fonts/icomoon.svg?-dllii#icomoon') format('svg');
8 | font-weight: normal;
9 | font-style: normal;
10 | }
11 |
12 | [class^="icon-"], [class*=" icon-"] {
13 | font-family: 'icomoon';
14 | speak: none;
15 | font-style: normal;
16 | font-weight: normal;
17 | font-variant: normal;
18 | text-transform: none;
19 | line-height: 1;
20 |
21 | /* Better Font Rendering =========== */
22 | -webkit-font-smoothing: antialiased;
23 | -moz-osx-font-smoothing: grayscale;
24 | }
25 |
26 | .icon-menu:before {
27 | content: "\e600";
28 | }
29 | .icon-home:before {
30 | content: "\e601";
31 | }
32 | .icon-list2:before {
33 | content: "\e602";
34 | }
35 | .icon-github:before {
36 | content: "\e603";
37 | }
38 | .icon-link-external:before {
39 | content: "\e605";
40 | }
41 | .icon-link:before {
42 | content: "\e606";
43 | }
44 | .icon-plus:before {
45 | content: "\e608";
46 | }
47 | .icon-facebook-square:before {
48 | content: "\e609";
49 | }
50 | .icon-chevron-right:before {
51 | content: "\e60a";
52 | }
53 | .icon-chevron-left:before {
54 | content: "\e60b";
55 | }
56 | .icon-arrow-right:before {
57 | content: "\e60e";
58 | }
59 | .icon-file-text2:before {
60 | content: "\e612";
61 | }
62 | .icon-refresh:before {
63 | content: "\e615";
64 | }
65 | .icon-in:before {
66 | content: "\e61a";
67 | }
68 | .icon-exclamation:before {
69 | content: "\e61c";
70 | }
71 | .icon-pencil2:before {
72 | content: "\e906";
73 | }
74 | .icon-bin:before {
75 | content: "\e9ac";
76 | }
77 | .icon-more:before {
78 | content: "\f833";
79 | }
80 | .icon-tools:before {
81 | content: "\e60c";
82 | }
83 | .icon-user:before {
84 | content: "\e604";
85 | }
86 | .icon-code:before {
87 | content: "\e607";
88 | }
89 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | OA-ElasticaSearch
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 | OA-ElasticaSearch
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/CustomFiltersScore.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.html
10 | */
11 | class Elastica_Query_CustomFiltersScore extends Elastica_Query_Abstract
12 | {
13 | /**
14 | * Sets a query
15 | *
16 | * @param Elastica_Query_Abstract $query Query object
17 | * @return Elastica_Query_CustomFiltersScore Current object
18 | */
19 | public function setQuery(Elastica_Query_Abstract $query)
20 | {
21 | $this->setParam('query', $query->toArray());
22 |
23 | return $this;
24 | }
25 |
26 | /**
27 | * Add a filter with boost
28 | *
29 | * @param Elastica_Filter_Abstract $filter Filter object
30 | * @param float $boost Boost for the filter
31 | * @return Elastica_Query_CustomFiltersScore Current object
32 | */
33 | public function addFilter(Elastica_Filter_Abstract $filter, $boost)
34 | {
35 | $filterParam = array('filter' => $filter->toArray(), 'boost' => $boost);
36 | $this->addParam('filters', $filterParam);
37 |
38 | return $this;
39 | }
40 |
41 | /**
42 | * Add a filter with a script to calculate the score
43 | *
44 | * @param Elastica_Filter_Abstract $filter Filter object
45 | * @param Elastica_Script $script Script for calculating the score
46 | * @return Elastica_Query_CustomFiltersScore Current object
47 | */
48 | public function addFilterScript(Elastica_Filter_Abstract $filter, Elastica_Script $script)
49 | {
50 | $filterParam = array('filter' => $filter->toArray(), 'script' => $script->getScript());
51 | $this->addParam('filters', $filterParam);
52 |
53 | return $this;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/guide/cmd/imports/_oa-mixins.scss:
--------------------------------------------------------------------------------
1 | /**
2 | * @author OA Wu
3 | * @copyright Copyright (c) 2016 OA Wu Design
4 | */
5 |
6 | @import "functions/_oa-input";
7 | @import "functions/_oa-hyperlink";
8 | @import "functions/_oa-alert";
9 | @import "functions/_oa-load";
10 | @import "functions/_oa-table";
11 | @import "functions/_oa-textarea";
12 |
13 | @import "functions/_oa-material";
14 |
15 | @mixin font-smoothing ($val: antialiased) {
16 | -moz-osx-font-smoothing: $val;
17 | -webkit-font-smoothing: $val;
18 | -moz-font-smoothing: $val;
19 | -ms-font-smoothing: $val;
20 | -o-font-smoothing: $val;
21 | }
22 |
23 | @mixin clearfix () {
24 | *zoom: 1;
25 |
26 | &:after {
27 | display: table;
28 | content: "";
29 | line-height: 0;
30 | clear: both;
31 | }
32 | }
33 |
34 | @mixin svg-color ($color: rgba(255, 255, 255, 1), $hoverColor: rgba(0, 0, 0, 1), $transition: all .3s) {
35 | &, * {
36 | color: $color;
37 | fill: $color;
38 | @include transition($transition);
39 | }
40 | &:hover {
41 | &, * {
42 | color: $hoverColor;
43 | fill: $hoverColor;
44 | }
45 | }
46 | }
47 | @mixin split ($leftName: '.l', $rightName: '.r') {
48 | @include clearfix();
49 |
50 | #{$leftName}, #{$rightName} {
51 | float: left;
52 | position: relative;
53 | display: inline-block;
54 | }
55 | #{$rightName} {
56 | float: right;
57 | }
58 | }
59 | @mixin split-left ($leftWidth: 100px, $leftName: '.l', $rightName: '.r') {
60 | @include split($leftName, $rightName);
61 |
62 | #{$leftName} {
63 | width: $leftWidth;
64 | }
65 | #{$rightName} {
66 | width: calc(100% - #{$leftWidth});
67 | }
68 | }
69 | @mixin split-right ($rightWidth: 100px, $leftName: '.l', $rightName: '.r') {
70 | @include split($leftName, $rightName);
71 |
72 | #{$leftName} {
73 | width: calc(100% - #{$rightWidth});
74 | }
75 | #{$rightName} {
76 | width: $rightWidth;
77 | }
78 | }
79 |
80 | @mixin overflow-docx3 () {
81 | overflow: hidden;
82 | text-overflow: ellipsis;
83 | white-space: nowrap;
84 | }
85 |
--------------------------------------------------------------------------------
/demo/Elastica/Facet/GeoDistance.php:
--------------------------------------------------------------------------------
1 |
8 | * @linkhttp://www.elasticsearch.org/guide/reference/api/search/facets/geo-distance-facet.html
9 | */
10 | class Elastica_Facet_GeoDistance extends Elastica_Facet_Abstract
11 | {
12 | /**
13 | * Sets the ranges for the facet all at once.
14 | * Sample ranges:
15 | * array (
16 | * array('to' => 50),
17 | * array('from' => 20, 'to' => 70),
18 | * array('from' => 70, 'to' => 120),
19 | * array('from' => 150)
20 | * )
21 | *
22 | * @param array $ranges Numerical array with range definitions.
23 | * @return Elastica_Facet_GeoDistance
24 | */
25 | public function setRanges(array $ranges)
26 | {
27 | return $this->setParam ( 'ranges', $ranges );
28 | }
29 |
30 | /**
31 | * Set the relative GeoPoint for the facet.
32 | *
33 | * @param string $typeField index type and field e.g foo.bar
34 | * @param float $latitude
35 | * @param float $longitude
36 | * @return Elastica_Facet_GeoDistance
37 | */
38 | public function setGeoPoint($typeField, $latitude, $longitude)
39 | {
40 | return $this->setParam ( $typeField, array (
41 | "lat" => $latitude,
42 | "lon" => $longitude
43 | ) );
44 | }
45 |
46 | /**
47 | * Creates the full facet definition, which includes the basic
48 | * facet definition of the parent.
49 | *
50 | * @see Elastica_Facet_Abstract::toArray()
51 | * @throws Elastica_Exception_Invalid When the right fields haven't been set.
52 | * @return array
53 | */
54 | public function toArray()
55 | {
56 | /**
57 | * Set the geo_distance in the abstract as param.
58 | */
59 | $this->_setFacetParam ( 'geo_distance', $this->_params );
60 |
61 | return parent::toArray ();
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/guide/cmd/command:
--------------------------------------------------------------------------------
1 |
2 | ◎ Commit
3 | =======================
4 | git add -A && git commit -m 'Fix html code.' && git push origin master
5 |
6 |
7 |
8 | ◎ Put S3 Command
9 | =======================
10 | ➜ Don't minify
11 | git add -A && git commit -m 'Fix code.' && git push origin master && cd guide/cmd && php put.php -b {bucket} -a {access} -s {secret} && cd ../..
12 |
13 | ➜ Need minify
14 | ➜ No installed npm
15 | -----------------------
16 | git add -A && git commit -m 'Fix code.' && cd guide/cmd && sudo npm install . && gulp minify && php put.php -b {bucket} -a {access} -s {secret} && cd ../.. && git checkout .
17 |
18 | ➜ Need minify
19 | ➜ Has installed npm
20 | -----------------------
21 | git add -A && git commit -m 'Fix code.' && cd guide/cmd && gulp minify && php put.php -b {bucket} -a {access} -s {secret} && cd ../.. && git checkout .
22 |
23 |
24 |
25 | ◎ No installed npm
26 | =======================
27 | ➜ No gh-pages branch
28 | git branch -v gh-pages && git checkout gh-pages && cd guide/cmd && sudo npm install . && gulp minify && gulp gh-pages && cd ../../ && git add -A && git commit -m 'Minify js、html, fix gh-pages path bug.' && git push origin gh-pages --force && git checkout master
29 |
30 | ➜ Has gh-pages branch
31 | git branch -D gh-pages && git branch -v gh-pages && git checkout gh-pages && cd guide/cmd && sudo npm install . && gulp minify && gulp gh-pages && cd ../../ && git add -A && git commit -m 'Minify js、html, fix gh-pages path bug.' && git push origin gh-pages --force && git checkout master
32 |
33 |
34 |
35 | ◎ Has installed npm
36 | =======================
37 | ➜ No gh-pages branch
38 | git branch -v gh-pages && git checkout gh-pages && cd guide/cmd && gulp minify && gulp gh-pages && cd ../../ && git add -A && git commit -m 'Minify js、html, fix gh-pages path bug.' && git push origin gh-pages --force && git checkout master
39 |
40 | ➜ Has gh-pages branch
41 | git branch -D gh-pages && git branch -v gh-pages && git checkout gh-pages && cd guide/cmd && gulp minify && gulp gh-pages && cd ../../ && git add -A && git commit -m 'Minify js、html, fix gh-pages path bug.' && git push origin gh-pages --force && git checkout master
42 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/Filtered.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/filtered-query.html
10 | */
11 | class Elastica_Query_Filtered extends Elastica_Query_Abstract
12 | {
13 | /**
14 | * Query
15 | *
16 | * @var Elastica_Query_Abstract Query object
17 | */
18 | protected $_query = null;
19 |
20 | /**
21 | * Filter
22 | *
23 | * @var Elastica_Filter_Abstract Filter object
24 | */
25 | protected $_filter = null;
26 |
27 | /**
28 | * Constructs a filtered query
29 | *
30 | * @param Elastica_Query_Abstract $query Query object
31 | * @param Elastica_Filter_Abstract $filter Filter object
32 | */
33 | public function __construct(Elastica_Query_Abstract $query, Elastica_Filter_Abstract $filter)
34 | {
35 | $this->setQuery($query);
36 | $this->setFilter($filter);
37 | }
38 |
39 | /**
40 | * Sets a query
41 | *
42 | * @param Elastica_Query_Abstract $query Query object
43 | * @return Elastica_Query_Filtered Current object
44 | */
45 | public function setQuery(Elastica_Query_Abstract $query)
46 | {
47 | $this->_query = $query;
48 |
49 | return $this;
50 | }
51 |
52 | /**
53 | * Sets the filter
54 | *
55 | * @param Elastica_Filter_Abstract $filter Filter object
56 | * @return Elastica_Query_Filtered Current object
57 | */
58 | public function setFilter(Elastica_Filter_Abstract $filter)
59 | {
60 | $this->_filter = $filter;
61 |
62 | return $this;
63 | }
64 |
65 | /**
66 | * Converts query to array
67 | *
68 | * @return array Query array
69 | * @see Elastica_Query_Abstract::toArray()
70 | */
71 | public function toArray()
72 | {
73 | return array('filtered' => array(
74 | 'query' => $this->_query->toArray(),
75 | 'filter' => $this->_filter->toArray()
76 | ));
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/Terms.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/terms-filter.html
10 | */
11 | class Elastica_Filter_Terms extends Elastica_Filter_Abstract
12 | {
13 | /**
14 | * Terms
15 | *
16 | * @var array Terms
17 | */
18 | protected $_terms = array();
19 |
20 | /**
21 | * Params
22 | *
23 | * @var array Params
24 | */
25 | protected $_params = array();
26 |
27 | /**
28 | * Terms key
29 | *
30 | * @var string Terms key
31 | */
32 | protected $_key = '';
33 |
34 | /**
35 | * Creates terms filter
36 | *
37 | * @param string $key Terms key
38 | * @param array $terms Terms values
39 | */
40 | public function __construct($key = '', array $terms = array())
41 | {
42 | $this->setTerms($key, $terms);
43 | }
44 |
45 | /**
46 | * Sets key and terms for the filter
47 | *
48 | * @param string $key Terms key
49 | * @param array $terms Terms for the query.
50 | */
51 | public function setTerms($key, array $terms)
52 | {
53 | $this->_key = $key;
54 | $this->_terms = array_values($terms);
55 |
56 | return $this;
57 | }
58 |
59 | /**
60 | * Adds an additional term to the query
61 | *
62 | * @param string $term Filter term
63 | * @return Elastica_Filter_Abstract Filter object
64 | */
65 | public function addTerm($term)
66 | {
67 | $this->_terms[] = $term;
68 |
69 | return $this;
70 | }
71 |
72 | /**
73 | * Convers object to an arrray
74 | *
75 | * @see Elastica_Filter_Abstract::toArray()
76 | * @return array data array
77 | */
78 | public function toArray()
79 | {
80 | if (empty($this->_key)) {
81 | throw new Elastica_Exception_Invalid('Terms key has to be set');
82 | }
83 | $this->_params[$this->_key] = $this->_terms;
84 |
85 | return array('terms' => $this->_params);
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/Field.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/field-query.html
10 | */
11 | class Elastica_Query_Field extends Elastica_Query_Abstract
12 | {
13 | /**
14 | * Field for object
15 | *
16 | * @var string Field for object
17 | */
18 | protected $_field = '';
19 |
20 | /**
21 | * Query string
22 | *
23 | * @var string Query string
24 | */
25 | protected $_queryString = '';
26 |
27 | /**
28 | * Creates field query object. Calls setField and setQuery with argument
29 | *
30 | * @param string $field OPTIONAL field for object
31 | * @param string $queryString OPTIONAL Query string for object
32 | */
33 | public function __construct($field = '', $queryString = '')
34 | {
35 | $this->setField($field);
36 | $this->setQueryString($queryString);
37 | }
38 |
39 | /**
40 | * Sets the field
41 | *
42 | * @param string $field Field
43 | * @return Elastica_Query_Field Current object
44 | */
45 | public function setField($field)
46 | {
47 | $this->_field = $field;
48 |
49 | return $this;
50 | }
51 |
52 | /**
53 | * Sets a new query string for the object
54 | *
55 | * @param string $queryString Query string
56 | * @return Elastica_Query_Field Current object
57 | */
58 | public function setQueryString($queryString)
59 | {
60 | if (!is_string($queryString)) {
61 | throw new Elastica_Exception_Invalid('Parameter has to be a string');
62 | }
63 |
64 | $this->_queryString = $queryString;
65 |
66 | return $this;
67 | }
68 |
69 | /**
70 | * Converts query to array
71 | *
72 | * @return array Query array
73 | * @see Elastica_Query_Abstract::toArray()
74 | */
75 | public function toArray()
76 | {
77 | $this->setParam($this->_field, array('query' => $this->_queryString));
78 |
79 | return parent::toArray();
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/Query.php:
--------------------------------------------------------------------------------
1 |
10 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/query-filter.html
11 | */
12 | class Elastica_Filter_Query extends Elastica_Filter_Abstract
13 | {
14 | /**
15 | * Query
16 | * @var array
17 | */
18 | protected $_query;
19 |
20 | /**
21 | * Construct query filter
22 | *
23 | * @param array|Elastica_Query_Abstract $query
24 | */
25 | public function __construct($query = null)
26 | {
27 | if (!is_null($query)) {
28 | $this->setQuery($query);
29 | }
30 | }
31 |
32 | /**
33 | * Set query
34 | *
35 | * @param array|Elastica_Query_Abstract $query
36 | * @return Elastca_Filter_Query Query object
37 | * @throws Elastica_Exception_Invalid Invalid param
38 | */
39 | public function setQuery($query)
40 | {
41 | if (!$query instanceof Elastica_Query_Abstract && ! is_array($query)) {
42 | throw new Elastica_Exception_Invalid('expected an array or instance of Elastica_Query_Abstract');
43 | }
44 |
45 | if ($query instanceof Elastica_Query_Abstract) {
46 | $query = $query->toArray();
47 | }
48 |
49 | $this->_query = $query;
50 |
51 | return $this;
52 | }
53 |
54 | /**
55 | * @see Elastica_Param::_getBaseName()
56 | */
57 | protected function _getBaseName()
58 | {
59 | if (empty($this->_params)) {
60 | return parent::_getBaseName();
61 | } else {
62 | return 'fquery';
63 | }
64 | }
65 |
66 | /**
67 | * @see Elastica_Param::toArray()
68 | */
69 | public function toArray()
70 | {
71 | $data = parent::toArray();
72 |
73 | $name = $this->_getBaseName();
74 | $filterData = $data[$name];
75 |
76 | if (empty($filterData)) {
77 | $filterData = $this->_query;
78 | } else {
79 | $filterData['query'] = $this->_query;
80 | }
81 |
82 | $data[$name] = $filterData;
83 |
84 | return $data;
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/demo/Elastica/Script.php:
--------------------------------------------------------------------------------
1 |
8 | * @link http://www.elasticsearch.org/guide/reference/modules/scripting.html
9 | */
10 | class Elastica_Script
11 | {
12 | /**
13 | * @var string
14 | */
15 | private $_script;
16 | /**
17 | * @var string
18 | */
19 | private $_lang;
20 | /**
21 | * @var array
22 | */
23 | private $_params;
24 |
25 | /**
26 | * @param string $script
27 | * @param array|null $params
28 | * @param string|null $lang
29 | */
30 | public function __construct($script, array $params = null, $lang = null)
31 | {
32 | $this->_script = $script;
33 | $this->_params = $params;
34 | $this->_lang = $lang;
35 | }
36 |
37 | /**
38 | * @param string $lang
39 | */
40 | public function setLang($lang)
41 | {
42 | $this->_lang = $lang;
43 | }
44 |
45 | /**
46 | * @return string
47 | */
48 | public function getLang()
49 | {
50 | return $this->_lang;
51 | }
52 |
53 | /**
54 | * @param array $params
55 | */
56 | public function setParams($params)
57 | {
58 | $this->_params = $params;
59 | }
60 |
61 | /**
62 | * @return array
63 | */
64 | public function getParams()
65 | {
66 | return $this->_params;
67 | }
68 |
69 | /**
70 | * @param string $script
71 | */
72 | public function setScript($script)
73 | {
74 | $this->_script = $script;
75 | }
76 |
77 | /**
78 | * @return string
79 | */
80 | public function getScript()
81 | {
82 | return $this->_script;
83 | }
84 |
85 | public function toArray()
86 | {
87 | $array = array(
88 | 'script' => $this->_script,
89 | );
90 | if ($this->_params) {
91 | $array['params'] = $this->_params;
92 | }
93 | if ($this->_lang) {
94 | $array['lang'] = $this->_lang;
95 | }
96 |
97 | return $array;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/Text.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/text-query.html
10 | */
11 | class Elastica_Query_Text extends Elastica_Query_Abstract
12 | {
13 | /**
14 | * Sets a param for the message array
15 | *
16 | * @param string $field
17 | * @param mixed $values
18 | * @return Elastica_Query_Text
19 | */
20 | public function setField($field, $values)
21 | {
22 | return $this->setParam($field, $values);
23 | }
24 |
25 | /**
26 | * Sets a param for the given field
27 | *
28 | * @param string $field
29 | * @param string $key
30 | * @param string $value
31 | * @return Elastica_Query_Text
32 | */
33 | public function setFieldParam($field, $key, $value)
34 | {
35 | if (!isset($this->_params[$field])) {
36 | $this->_params[$field] = array();
37 | }
38 |
39 | $this->_params[$field][$key] = $value;
40 |
41 | return $this;
42 | }
43 |
44 | /**
45 | * Sets the query string
46 | *
47 | * @param string $field
48 | * @param string $query
49 | * @return Elastica_Query_Text
50 | */
51 | public function setFieldQuery($field, $query)
52 | {
53 | return $this->setFieldParam($field, 'query', $query);
54 | }
55 |
56 | /**
57 | * Set field type
58 | *
59 | * @param string $field
60 | * @param string $type Text query type
61 | * @return Elastica_Query_Text
62 | */
63 | public function setFieldType($field, $type)
64 | {
65 | return $this->setFieldParam($field, 'type', $type);
66 | }
67 |
68 | /**
69 | * Set field max expansions
70 | *
71 | * @param string $field
72 | * @param int $maxExpansions
73 | * @return Elastica_Query_Text
74 | */
75 | public function setFieldMaxExpansions($field, $maxExpansions)
76 | {
77 | return $this->setFieldParam($field, 'max_expansions', $maxExpansions);
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/demo/Elastica/Transport/Memcache.php:
--------------------------------------------------------------------------------
1 |
8 | */
9 | class Elastica_Transport_Memcache extends Elastica_Transport_Abstract
10 | {
11 | /**
12 | * Makes calls to the elasticsearch server
13 | *
14 | * @param array $params Host, Port, ...
15 | * @return Elastica_Response Response object
16 | */
17 | public function exec(array $params)
18 | {
19 | $request = $this->getRequest();
20 |
21 | $memcache = new Memcache();
22 | $memcache->connect($params['host'], $params['port']);
23 |
24 | // Finds right function name
25 | $function = strtolower($request->getMethod());
26 |
27 | $data = $request->getData();
28 |
29 | $content = '';
30 |
31 | if (!empty($data)) {
32 | if (is_array($data)) {
33 | $content = json_encode($data);
34 | } else {
35 | $content = $data;
36 | }
37 |
38 | // Escaping of / not necessary. Causes problems in base64 encoding of files
39 | $content = str_replace('\/', '/', $content);
40 | }
41 |
42 | $responseString = '';
43 |
44 | switch ($function) {
45 | case 'post':
46 | case 'put':
47 | $memcache->set($request->getPath(), $content);
48 | break;
49 | case 'get':
50 | $responseString = $memcache->get($request->getPath() . '?source=' . $content);
51 | echo $responseString . PHP_EOL;
52 | break;
53 | case 'delete':
54 | break;
55 | default:
56 | throw new Elastica_Exception_Invalid('Method ' . $function . ' is not supported in memcache transport');
57 |
58 | }
59 |
60 | $response = new Elastica_Response($responseString);
61 |
62 | if (defined('DEBUG') && DEBUG) {
63 | $response->setQueryTime($end - $start);
64 | $response->setTransferInfo(curl_getinfo($conn));
65 | }
66 |
67 | if ($response->hasError()) {
68 | throw new Elastica_Exception_Response($response);
69 | }
70 |
71 | return $response;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/Terms.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/terms-query.html
10 | */
11 | class Elastica_Query_Terms extends Elastica_Query_Abstract
12 | {
13 | /**
14 | * Terms
15 | *
16 | * @var array Terms
17 | */
18 | protected $_terms = array();
19 |
20 | /**
21 | * Params
22 | *
23 | * @var array Params
24 | */
25 | protected $_params = array();
26 |
27 | /**
28 | * Terms key
29 | *
30 | * @var string Terms key
31 | */
32 | protected $_key = '';
33 |
34 | /**
35 | * Construct terms query
36 | *
37 | * @param string $key OPTIONAL Terms key
38 | * @param array $terms OPTIONAL Terms list
39 | */
40 | public function __construct($key = '', array $terms = array())
41 | {
42 | $this->setTerms($key, $terms);
43 | }
44 |
45 | /**
46 | * Sets key and terms for the query
47 | *
48 | * @param string $key Terms key
49 | * @param array $terms Terms for the query.
50 | */
51 | public function setTerms($key, array $terms)
52 | {
53 | $this->_key = $key;
54 | $this->_terms = array_values($terms);
55 |
56 | return $this;
57 | }
58 |
59 | /**
60 | * Adds a single term to the list
61 | *
62 | * @param string $term Term
63 | */
64 | public function addTerm($term)
65 | {
66 | $this->_terms[] = $term;
67 |
68 | return $this;
69 | }
70 |
71 | /**
72 | * Sets the minimum matching values
73 | *
74 | * @param int $minimum Minimum value
75 | */
76 | public function setMinimumMatch($minimum)
77 | {
78 | return $this->setParam('minimum_match', (int) $minimum);
79 | }
80 |
81 | /**
82 | * Converts the terms object to an array
83 | *
84 | * @return array Query array
85 | * @see Elastica_Query_Abstract::toArray()
86 | */
87 | public function toArray()
88 | {
89 | if (empty($this->_key)) {
90 | throw new Elastica_Exception_Invalid('Terms key has to be set');
91 | }
92 | $this->setParam($this->_key, $this->_terms);
93 |
94 | return parent::toArray();
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/guide/js/prettify/prettify.css:
--------------------------------------------------------------------------------
1 | /* Pretty printing styles. Used with prettify.js. */
2 |
3 | /* SPAN elements with the classes below are added by prettyprint. */
4 | .pln { color: #000 } /* plain text */
5 |
6 | @media screen {
7 | .str { color: #080 } /* string content */
8 | .kwd { color: #008 } /* a keyword */
9 | .com { color: #800 } /* a comment */
10 | .typ { color: #606 } /* a type name */
11 | .lit { color: #066 } /* a literal value */
12 | /* punctuation, lisp open bracket, lisp close bracket */
13 | .pun, .opn, .clo { color: #660 }
14 | .tag { color: #008 } /* a markup tag name */
15 | .atn { color: #606 } /* a markup attribute name */
16 | .atv { color: #080 } /* a markup attribute value */
17 | .dec, .var { color: #606 } /* a declaration; a variable name */
18 | .fun { color: red } /* a function name */
19 | }
20 |
21 | /* Use higher contrast and text-weight for printable form. */
22 | @media print, projection {
23 | .str { color: #060 }
24 | .kwd { color: #006; font-weight: bold }
25 | .com { color: #600; font-style: italic }
26 | .typ { color: #404; font-weight: bold }
27 | .lit { color: #044 }
28 | .pun, .opn, .clo { color: #440 }
29 | .tag { color: #006; font-weight: bold }
30 | .atn { color: #404 }
31 | .atv { color: #060 }
32 | }
33 |
34 | /* Put a border around prettyprinted code snippets. */
35 | pre.prettyprint { padding: 2px; border: 1px solid #888 }
36 |
37 | /* Specify class=linenums on a pre to get line numbering */
38 | ol.linenums { margin-top: 0; margin-bottom: 0 } /* IE indents via margin-left */
39 | li.L0,
40 | li.L1,
41 | li.L2,
42 | li.L3,
43 | li.L5,
44 | li.L6,
45 | li.L7,
46 | li.L8 { list-style-type: none }
47 | /* Alternate shading for lines */
48 | li.L1,
49 | li.L3,
50 | li.L5,
51 | li.L7,
52 | li.L9 { background: #eee }
53 |
54 | li.L0,
55 | li.L2,
56 | li.L4,
57 | li.L6,
58 | li.L8 { background: #ddd }
59 |
60 | li.L0, li.L1, li.L2, li.L3, li.L5, li.L6, li.L7, li.L8, li.L9 {
61 | list-style-type: decimal !important;
62 | }
63 |
64 | .prettyprint {
65 | margin-bottom: 0px !important;
66 | text-align: left;
67 | }
68 | .prettyprint .filepath {
69 | background-color: #eee;
70 |
71 | border-bottom: 1px solid #777;
72 | font-size: 12px;
73 | text-align: right;
74 | font-style: italic;
75 | color: #888;
76 | }
77 |
78 | .prettyprint .filepath:before {
79 | content: "File : ";
80 | float: left;
81 | color: #555;
82 | }
83 | .prettyprint ol.linenums li {
84 | border-left: 1px solid #777;
85 | }
--------------------------------------------------------------------------------
/demo/Elastica/Percolator.php:
--------------------------------------------------------------------------------
1 |
8 | * @link http://www.elasticsearch.org/guide/reference/api/percolate.html
9 | */
10 | class Elastica_Percolator
11 | {
12 | /**
13 | * Index object
14 | *
15 | * @var Elastica_Index
16 | */
17 | protected $_index = null;
18 |
19 | /**
20 | * Construct new perlocator
21 | *
22 | * @param Elastica_Index $index
23 | */
24 | public function __construct(Elastica_Index $index)
25 | {
26 | $this->_index = $index;
27 | }
28 |
29 | /**
30 | * Registers a percolator query
31 | *
32 | * @param string $name Query name
33 | * @param string|Elastica_Query|Elastica_Query_Abstract $query Query to add
34 | * @return Elastica_Response
35 | */
36 | public function registerQuery($name, $query)
37 | {
38 | $path = '_percolator/' . $this->_index->getName() . '/' . $name;
39 | $query = Elastica_Query::create($query);
40 |
41 | return $this->_index->getClient()->request($path, Elastica_Request::PUT, $query->toArray());
42 | }
43 |
44 | /**
45 | * Removes a percolator query
46 | * @param string $name query name
47 | * @return Elastica_Response
48 | */
49 | public function unregisterQuery($name)
50 | {
51 | $path = '_percolator/' . $this->_index->getName() . '/' . $name;
52 |
53 | return $this->_index->getClient()->request($path, Elastica_Request::DELETE);
54 | }
55 |
56 | /**
57 | * Match a document to percolator queries
58 | *
59 | * @param Elastica_Document $doc
60 | * @param string|Elastica_Query|Elastica_Query_Abstract $query Not implemented yet
61 | * @return Elastica_Response
62 | */
63 | public function matchDoc(Elastica_Document $doc, $query = null)
64 | {
65 | $path = $this->_index->getName() . '/type/_percolate';
66 | $data = array('doc' => $doc->getData());
67 |
68 | $response = $this->getIndex()->getClient()->request($path, Elastica_Request::GET, $data);
69 | $data = $response->getData();
70 |
71 | return $data['matches'];
72 | }
73 |
74 | /**
75 | * Return index object
76 | *
77 | * @return Elastica_Index
78 | */
79 | public function getIndex()
80 | {
81 | return $this->_index;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/demo/Elastica/Index/Stats.php:
--------------------------------------------------------------------------------
1 |
8 | * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-stats.html
9 | */
10 | class Elastica_Index_Stats
11 | {
12 | /**
13 | * Response
14 | *
15 | * @var Elastica_Response Response object
16 | */
17 | protected $_response = null;
18 |
19 | /**
20 | * Stats info
21 | *
22 | * @var array Stats info
23 | */
24 | protected $_data = array();
25 |
26 | /**
27 | * Index
28 | *
29 | * @var Elastica_Index Index object
30 | */
31 | protected $_index = null;
32 |
33 | /**
34 | * Construct
35 | *
36 | * @param Elastica_Index $index Index object
37 | */
38 | public function __construct(Elastica_Index $index)
39 | {
40 | $this->_index = $index;
41 | $this->refresh();
42 | }
43 |
44 | /**
45 | * Returns the raw stats info
46 | *
47 | * @return array Stats info
48 | */
49 | public function getData()
50 | {
51 | return $this->_data;
52 | }
53 |
54 | /**
55 | * Returns the entry in the data array based on the params.
56 | * Various params possible.
57 | *
58 | * @return mixed Data array entry or null if not found
59 | */
60 | public function get()
61 | {
62 | $data = $this->getData();
63 |
64 | foreach (func_get_args() as $arg) {
65 | if (isset($data[$arg])) {
66 | $data = $data[$arg];
67 | } else {
68 | return null;
69 | }
70 | }
71 |
72 | return $data;
73 | }
74 |
75 | /**
76 | * Returns the index object
77 | *
78 | * @return Elastica_Index Index object
79 | */
80 | public function getIndex()
81 | {
82 | return $this->_index;
83 | }
84 |
85 | /**
86 | * Returns response object
87 | *
88 | * @return Elastica_Response Response object
89 | */
90 | public function getResponse()
91 | {
92 | return $this->_response;
93 | }
94 |
95 | /**
96 | * Reloads all status data of this object
97 | */
98 | public function refresh()
99 | {
100 | $path = '_stats';
101 | $this->_response = $this->getIndex()->request($path, Elastica_Request::GET);
102 | $this->_data = $this->getResponse()->getData();
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/Ids.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/ids-filter.html
10 | */
11 | class Elastica_Filter_Ids extends Elastica_Filter_Abstract
12 | {
13 | /**
14 | * Creates filter object
15 | *
16 | * @param string|Elastica_Type $type Type to filter on
17 | * @param array $ids List of ids
18 | */
19 | public function __construct($type = null, array $ids = array())
20 | {
21 | $this->setType($type);
22 | $this->setIds($ids);
23 | }
24 |
25 | /**
26 | * Adds one more filter to the and filter
27 | *
28 | * @param string $id Adds id to filter
29 | * @return Elastica_Filter_Ids Current object
30 | */
31 | public function addId($id)
32 | {
33 | return $this->addParam('values', $id);
34 | }
35 |
36 | /**
37 | * Adds one more type to query
38 | *
39 | * @param string $type Adds type to query
40 | * @return Elastica_Filter_Ids Current object
41 | */
42 | public function addType($type)
43 | {
44 | if ($type instanceof Elastica_Type) {
45 | $type = $type->getType();
46 | } elseif (empty($type) && !is_numeric($type)) {
47 | // TODO: Shouldn't this throw an exception?
48 | // A type can be 0, but cannot be empty
49 | return $this;
50 | }
51 |
52 | return $this->addParam('type', $type);
53 | }
54 |
55 | /**
56 | * Set type
57 | *
58 | * @param string|Elastica_Type $type Type name or object
59 | * @return Elastica_Filter_Ids Current object
60 | */
61 | public function setType($type)
62 | {
63 | if ($type instanceof Elastica_Type) {
64 | $type = $type->getType();
65 | } elseif (empty($type) && !is_numeric($type)) {
66 | // TODO: Shouldn't this throw an exception or let handling of invalid params to ES?
67 | // A type can be 0, but cannot be empty
68 | return $this;
69 | }
70 |
71 | return $this->setParam('type', $type);
72 | }
73 |
74 | /**
75 | * Sets the ids to filter
76 | *
77 | * @param array|string $ids List of ids
78 | * @return Elastica_Filter_Ids Current object
79 | */
80 | public function setIds($ids)
81 | {
82 | if (!is_array($ids)) {
83 | $ids = array($ids);
84 | }
85 |
86 | return $this->setParam('values', $ids);
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/Bool.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html
10 | */
11 | class Elastica_Query_Bool extends Elastica_Query_Abstract
12 | {
13 | /**
14 | * Add should part to query
15 | *
16 | * @param Elastica_Query_Abstract|array $args Should query
17 | * @return Elastica_Query_Bool Current object
18 | */
19 | public function addShould($args)
20 | {
21 | return $this->_addQuery('should', $args);
22 | }
23 |
24 | /**
25 | * Add must part to query
26 | *
27 | * @param Elastica_Query_Abstract|array $args Must query
28 | * @return Elastica_Query_Bool Current object
29 | */
30 | public function addMust($args)
31 | {
32 | return $this->_addQuery('must', $args);
33 | }
34 |
35 | /**
36 | * Add must not part to query
37 | *
38 | * @param Elastica_Query_Abstract|array $args Must not query
39 | * @return Elastica_Query_Bool Current object
40 | */
41 | public function addMustNot($args)
42 | {
43 | return $this->_addQuery('must_not', $args);
44 | }
45 |
46 | /**
47 | * Adds a query to the current object
48 | *
49 | * @param string $type Query type
50 | * @param Elastica_Query_Abstract|array $args Query
51 | * @throws Elastica_Exception_Invalid If not valid query
52 | */
53 | protected function _addQuery($type, $args)
54 | {
55 | if ($args instanceof Elastica_Query_Abstract) {
56 | $args = $args->toArray();
57 | }
58 |
59 | if (!is_array($args)) {
60 | throw new Elastica_Exception_Invalid('Invalid parameter. Has to be array or instance of Elastica_Query');
61 | }
62 |
63 | return $this->addParam($type, $args);
64 | }
65 |
66 | /**
67 | * Sets boost value of this query
68 | *
69 | * @param float $boost Boost value
70 | * @return Elastica_Query_Bool Current object
71 | */
72 | public function setBoost($boost)
73 | {
74 | return $this->setParam('boost', $boost);
75 | }
76 |
77 | /**
78 | * Set the minimum number of of should match
79 | *
80 | * @param int $minimumNumberShouldMatch Should match minimum
81 | * @return Elastica_Query_Bool Current object
82 | */
83 | public function setMinimumNumberShouldMatch($minimumNumberShouldMatch)
84 | {
85 | return $this->setParam('minimum_number_should_match', $minimumNumberShouldMatch);
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/demo/Elastica/Facet/Histogram.php:
--------------------------------------------------------------------------------
1 |
8 | * @link http://www.elasticsearch.org/guide/reference/api/search/facets/histogram-facet.html
9 | */
10 | class Elastica_Facet_Histogram extends Elastica_Facet_Abstract
11 | {
12 | /**
13 | * Sets the field for histogram
14 | *
15 | * @param string $field The name of the field for the historgram
16 | * @return Elastica_Facet_Histogram
17 | */
18 | public function setField($field)
19 | {
20 | return $this->setParam('field', $field);
21 | }
22 |
23 | /**
24 | * Set the value for interval
25 | *
26 | * @param string $interval
27 | * @return Elastica_Facet_Range
28 | */
29 | public function setInterval($interval)
30 | {
31 | return $this->setParam('interval', $interval);
32 | }
33 |
34 | /**
35 | * Set the fields for key_field and value_field
36 | *
37 | * @param string $keyField Key field
38 | * @param string $valueField Value field
39 | * @return Elastica_Facet_Range
40 | */
41 | public function setKeyValueFields($keyField, $valueField)
42 | {
43 | return $this->setParam('key_field', $keyField)->setParam('value_field', $valueField);
44 | }
45 |
46 | /**
47 | * Sets the key and value for this facet by script.
48 | *
49 | * @param string $keyScript Script to check whether it falls into the range.
50 | * @param string $valueScript Script to use for statistical calculations.
51 | */
52 | public function setKeyValueScripts($keyScript, $valueScript)
53 | {
54 | return $this->setParam('key_script', $keyScript)
55 | ->setParam('value_script', $valueScript);
56 | }
57 |
58 | /**
59 | * Set the "params" essential to the a script
60 | *
61 | * @param array $params Associative array (key/value pair)
62 | * @return Elastica_Facet_Histogram Facet object
63 | */
64 | public function setScriptParams(array $params)
65 | {
66 | return $this->setParam('params', $params);
67 | }
68 |
69 | /**
70 | * Creates the full facet definition, which includes the basic
71 | * facet definition of the parent.
72 | *
73 | * @see Elastica_Facet_Abstract::toArray()
74 | * @throws Elastica_Exception_Invalid When the right fields haven't been set.
75 | * @return array
76 | */
77 | public function toArray()
78 | {
79 | /**
80 | * Set the range in the abstract as param.
81 | */
82 | $this->_setFacetParam('histogram', $this->_params);
83 |
84 | return parent::toArray();
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/demo/Elastica/Node/Stats.php:
--------------------------------------------------------------------------------
1 |
8 | * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-status.html
9 | */
10 | class Elastica_Node_Stats
11 | {
12 | /**
13 | * Response
14 | *
15 | * @var Elastica_Response Response object
16 | */
17 | protected $_response = null;
18 |
19 | /**
20 | * Stats data
21 | *
22 | * @var array stats data
23 | */
24 | protected $_data = array();
25 |
26 | /**
27 | * Node
28 | *
29 | * @var Elastica_Node Node object
30 | */
31 | protected $_node = null;
32 |
33 | /**
34 | * Create new stats for node
35 | *
36 | * @param Elastica_Node $node Elastica node object
37 | */
38 | public function __construct(Elastica_Node $node)
39 | {
40 | $this->_node = $node;
41 | $this->refresh();
42 | }
43 |
44 | /**
45 | * Returns all node stats as array based on the arguments
46 | *
47 | * Several arguments can be use
48 | * get('index', 'test', 'example')
49 | *
50 | * @return array Node stats for the given field or null if not found
51 | */
52 | public function get()
53 | {
54 | $data = $this->getData();
55 |
56 | foreach (func_get_args() as $arg) {
57 | if (isset($data[$arg])) {
58 | $data = $data[$arg];
59 | } else {
60 | return null;
61 | }
62 | }
63 |
64 | return $data;
65 | }
66 |
67 | /**
68 | * Returns all stats data
69 | *
70 | * @return array Data array
71 | */
72 | public function getData()
73 | {
74 | return $this->_data;
75 | }
76 |
77 | /**
78 | * Returns node object
79 | *
80 | * @return Elastica_Node Node object
81 | */
82 | public function getNode()
83 | {
84 | return $this->_node;
85 | }
86 |
87 | /**
88 | * Returns response object
89 | *
90 | * @return Elastica_Response Response object
91 | */
92 | public function getResponse()
93 | {
94 | return $this->_response;
95 | }
96 |
97 | /**
98 | * Reloads all nodes information. Has to be called if informations changed
99 | *
100 | * @return Elastica_Response Response object
101 | */
102 | public function refresh()
103 | {
104 | $path = '_cluster/nodes/' . $this->getNode()->getName() . '/stats';
105 | $this->_response = $this->getNode()->getClient()->request($path, Elastica_Request::GET);
106 | $data = $this->getResponse()->getData();
107 | $this->_data = reset($data['nodes']);
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/guide/font/icomoon/icomoon/demo-files/demo.css:
--------------------------------------------------------------------------------
1 | body {
2 | padding: 0;
3 | margin: 0;
4 | font-family: sans-serif;
5 | font-size: 1em;
6 | line-height: 1.5;
7 | color: #555;
8 | background: #fff;
9 | }
10 | h1 {
11 | font-size: 1.5em;
12 | font-weight: normal;
13 | }
14 | small {
15 | font-size: .66666667em;
16 | }
17 | a {
18 | color: #e74c3c;
19 | text-decoration: none;
20 | }
21 | a:hover, a:focus {
22 | box-shadow: 0 1px #e74c3c;
23 | }
24 | .bshadow0, input {
25 | box-shadow: inset 0 -2px #e7e7e7;
26 | }
27 | input:hover {
28 | box-shadow: inset 0 -2px #ccc;
29 | }
30 | input, fieldset {
31 | font-size: 1em;
32 | margin: 0;
33 | padding: 0;
34 | border: 0;
35 | }
36 | input {
37 | color: inherit;
38 | line-height: 1.5;
39 | height: 1.5em;
40 | padding: .25em 0;
41 | }
42 | input:focus {
43 | outline: none;
44 | box-shadow: inset 0 -2px #449fdb;
45 | }
46 | .glyph {
47 | font-size: 16px;
48 | width: 15em;
49 | padding-bottom: 1em;
50 | margin-right: 4em;
51 | margin-bottom: 1em;
52 | float: left;
53 | overflow: hidden;
54 | }
55 | .liga {
56 | width: 80%;
57 | width: calc(100% - 2.5em);
58 | }
59 | .talign-right {
60 | text-align: right;
61 | }
62 | .talign-center {
63 | text-align: center;
64 | }
65 | .bgc1 {
66 | background: #f1f1f1;
67 | }
68 | .fgc1 {
69 | color: #999;
70 | }
71 | .fgc0 {
72 | color: #000;
73 | }
74 | p {
75 | margin-top: 1em;
76 | margin-bottom: 1em;
77 | }
78 | .mvm {
79 | margin-top: .75em;
80 | margin-bottom: .75em;
81 | }
82 | .mtn {
83 | margin-top: 0;
84 | }
85 | .mtl, .mal {
86 | margin-top: 1.5em;
87 | }
88 | .mbl, .mal {
89 | margin-bottom: 1.5em;
90 | }
91 | .mal, .mhl {
92 | margin-left: 1.5em;
93 | margin-right: 1.5em;
94 | }
95 | .mhmm {
96 | margin-left: 1em;
97 | margin-right: 1em;
98 | }
99 | .mls {
100 | margin-left: .25em;
101 | }
102 | .ptl {
103 | padding-top: 1.5em;
104 | }
105 | .pbs, .pvs {
106 | padding-bottom: .25em;
107 | }
108 | .pvs, .pts {
109 | padding-top: .25em;
110 | }
111 | .unit {
112 | float: left;
113 | }
114 | .unitRight {
115 | float: right;
116 | }
117 | .size1of2 {
118 | width: 50%;
119 | }
120 | .size1of1 {
121 | width: 100%;
122 | }
123 | .clearfix:before, .clearfix:after {
124 | content: " ";
125 | display: table;
126 | }
127 | .clearfix:after {
128 | clear: both;
129 | }
130 | .hidden-true {
131 | display: none;
132 | }
133 | .textbox0 {
134 | width: 3em;
135 | background: #f1f1f1;
136 | padding: .25em .5em;
137 | line-height: 1.5;
138 | height: 1.5em;
139 | }
140 | #testDrive {
141 | display: block;
142 | padding-top: 24px;
143 | line-height: 1.5;
144 | }
145 | .fs0 {
146 | font-size: 16px;
147 | }
148 | .fs1 {
149 | font-size: 32px;
150 | }
151 | .fs2 {
152 | font-size: 32px;
153 | }
154 | .fs3 {
155 | font-size: 32px;
156 | }
157 | .fs4 {
158 | font-size: 20px;
159 | }
160 |
--------------------------------------------------------------------------------
/demo/Elastica/Log.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 | class Elastica_Log
11 | {
12 | /**
13 | * Log path or true if enabled
14 | *
15 | * @var string|bool
16 | */
17 | protected $_log = false;
18 |
19 | /**
20 | * Last logged message
21 | *
22 | * @var string Last logged message
23 | */
24 | protected $_lastMessage = '';
25 |
26 | /**
27 | * Inits log object. Checks if logging is enabled for the given client
28 | *
29 | * @param Elastica_Client $client
30 | */
31 | public function __construct(Elastica_Client $client)
32 | {
33 | $this->setLog($client->getConfig('log'));
34 | }
35 |
36 | /**
37 | * Log a message
38 | *
39 | * @param string|Elastica_Request $message
40 | */
41 | public function log($message)
42 | {
43 | if (!$this->_log) {
44 | return;
45 | }
46 |
47 | if ($message instanceof Elastica_Request) {
48 | $message = $this->_convertRequest($message);
49 | }
50 |
51 | $this->_lastMessage = $message;
52 |
53 | if (is_string($this->_log)) {
54 | error_log($message . PHP_EOL, 3, $this->_log);
55 | } else {
56 | error_log($message);
57 | }
58 |
59 | }
60 |
61 | /**
62 | * Enable/disable log or set log path
63 | *
64 | * @param bool|string $log Enables log or sets log path
65 | * @return Elastica_Log
66 | */
67 | public function setLog($log)
68 | {
69 | $this->_log = $log;
70 |
71 | return $this;
72 | }
73 |
74 | /**
75 | * Converts a request to a log message
76 | *
77 | * @param Elastica_Request $request
78 | * @return string Request log message
79 | */
80 | protected function _convertRequest(Elastica_Request $request)
81 | {
82 | $message = 'curl -X' . strtoupper($request->getMethod()) . ' ';
83 | $message .= '\'http://' . $request->getClient()->getHost() . ':' . $request->getClient()->getPort() . '/';
84 | $message .= $request->getPath();
85 |
86 | $query = $request->getQuery();
87 | if (!empty($query)) {
88 | $message .= '?' . http_build_query($query);
89 | }
90 |
91 | $message .= '\'';
92 |
93 | $data = $request->getData();
94 | if (!empty($data)) {
95 | $message .= ' -d \'' . json_encode($data) . '\'';
96 | }
97 |
98 | return $message;
99 | }
100 |
101 | /**
102 | * Return last logged message
103 | *
104 | * @return string Last logged message
105 | */
106 | public function getLastMessage()
107 | {
108 | return $this->_lastMessage;
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/guide/scss/prettify/prettify.scss:
--------------------------------------------------------------------------------
1 | /**
2 | * @author OA Wu
3 | * @copyright Copyright (c) 2015 OA Wu Design
4 | */
5 |
6 | @import "_oa";
7 |
8 | /* Pretty printing styles. Used with prettify.js. */
9 |
10 | /* SPAN elements with the classes below are added by prettyprint. */
11 | .pln { color: #000 } /* plain text */
12 |
13 | @media screen {
14 | .str { color: #080 } /* string content */
15 | .kwd { color: #008 } /* a keyword */
16 | .com { color: #800 } /* a comment */
17 | .typ { color: #606 } /* a type name */
18 | .lit { color: #066 } /* a literal value */
19 | /* punctuation, lisp open bracket, lisp close bracket */
20 | .pun, .opn, .clo { color: #660 }
21 | .tag { color: #008 } /* a markup tag name */
22 | .atn { color: #606 } /* a markup attribute name */
23 | .atv { color: #080 } /* a markup attribute value */
24 | .dec, .var { color: #606 } /* a declaration; a variable name */
25 | .fun { color: red } /* a function name */
26 | }
27 |
28 | /* Use higher contrast and text-weight for printable form. */
29 | @media print, projection {
30 | .str { color: #060 }
31 | .kwd { color: #006; font-weight: bold }
32 | .com { color: #600; font-style: italic }
33 | .typ { color: #404; font-weight: bold }
34 | .lit { color: #044 }
35 | .pun, .opn, .clo { color: #440 }
36 | .tag { color: #006; font-weight: bold }
37 | .atn { color: #404 }
38 | .atv { color: #060 }
39 | }
40 |
41 | /* Put a border around prettyprinted code snippets. */
42 | pre.prettyprint { padding: 2px; border: 1px solid #888 }
43 |
44 | /* Specify class=linenums on a pre to get line numbering */
45 | ol.linenums { margin-top: 0; margin-bottom: 0 } /* IE indents via margin-left */
46 | li.L0,
47 | li.L1,
48 | li.L2,
49 | li.L3,
50 | li.L5,
51 | li.L6,
52 | li.L7,
53 | li.L8 { list-style-type: none }
54 | /* Alternate shading for lines */
55 | li.L1,
56 | li.L3,
57 | li.L5,
58 | li.L7,
59 | li.L9 { background: #eee }
60 |
61 | li.L0,
62 | li.L2,
63 | li.L4,
64 | li.L6,
65 | li.L8 { background: #ddd }
66 |
67 | li.L0, li.L1, li.L2, li.L3, li.L5, li.L6, li.L7, li.L8, li.L9 {
68 | list-style-type: decimal !important;
69 | }
70 |
71 | .prettyprint {
72 | margin-bottom: 0px !important;
73 | text-align: left;
74 |
75 | .filepath {
76 | background-color: #eee;
77 |
78 | border-bottom: 1px solid #777;
79 | font-size: 12px;
80 | text-align: right;
81 | font-style: italic;
82 | color: #888;
83 |
84 | &:before {
85 | content: "File : ";
86 | float: left;
87 | color: #555;
88 | }
89 | }
90 | ol.linenums {
91 | li {
92 | border-left: 1px solid rgba(39, 40, 34, .3);
93 | word-break: break-all;
94 | padding: 0;
95 | padding-left: 4px;
96 | @include clearfix();
97 |
98 | span {
99 | float: left;
100 | display: inline-block;
101 | margin-top: -12px;
102 | margin-bottom: 5px;
103 | }
104 | &:last-child {
105 | display: none;
106 | }
107 | }
108 | }
109 | }
--------------------------------------------------------------------------------
/demo/Elastica/Node.php:
--------------------------------------------------------------------------------
1 |
8 | * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-status.html
9 | */
10 | class Elastica_Node
11 | {
12 | /**
13 | * Node name
14 | *
15 | * @var string Node name
16 | */
17 | protected $_name = '';
18 |
19 | /**
20 | * Node stats
21 | *
22 | * @var Elastica_Node_Stats Node Stats
23 | */
24 | protected $_stats = null;
25 |
26 | /**
27 | * Node info
28 | *
29 | * @var Elastica_Node_Info Node info
30 | */
31 | protected $_info = null;
32 |
33 | /**
34 | * Create a new node object
35 | *
36 | * @param string $name Node name
37 | * @param Elastica_Client $client Node object
38 | */
39 | public function __construct($name, Elastica_Client $client)
40 | {
41 | $this->_name = $name;
42 | $this->_client = $client;
43 | $this->refresh();
44 | }
45 |
46 | /**
47 | * Get the name of the node
48 | *
49 | * @return string Node name
50 | */
51 | public function getName()
52 | {
53 | return $this->_name;
54 | }
55 |
56 | /**
57 | * Returns the current client object
58 | *
59 | * @return Elastica_Client Client
60 | */
61 | public function getClient()
62 | {
63 | return $this->_client;
64 | }
65 |
66 | /**
67 | * Return stats object of the current node
68 | *
69 | * @return Elastica_Node_Stats Node stats
70 | */
71 | public function getStats()
72 | {
73 | if (!$this->_stats) {
74 | $this->_stats = new Elastica_Node_Stats($this);
75 | }
76 |
77 | return $this->_stats;
78 | }
79 |
80 | /**
81 | * Return info object of the current node
82 | *
83 | * @return Elastica_Node_Info Node info object
84 | */
85 | public function getInfo()
86 | {
87 | if (!$this->_info) {
88 | $this->_info = new Elastica_Node_Info($this);
89 | }
90 |
91 | return $this->_info;
92 | }
93 |
94 | /**
95 | * Refreshs all node information
96 | *
97 | * This should be called after upating a node to refresh all information
98 | */
99 | public function refresh()
100 | {
101 | $this->_stats = null;
102 | $this->_info = null;
103 | }
104 |
105 | /**
106 | * Shuts this node down
107 | *
108 | * @param string $delay OPTIONAL Delay after which node is shut down (defualt = 1s)
109 | * @return Elastica_Response
110 | * @link http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown.html
111 | */
112 | public function shutdown($delay = '1s')
113 | {
114 | $path = '_cluster/nodes/' . $this->getName() . '/_shutdown?delay=' . $delay;
115 |
116 | return $this->_client->request($path, Elastica_Request::POST);
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/Ids.php:
--------------------------------------------------------------------------------
1 |
10 | * @author Tim Rupp
11 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/ids-query.html
12 | */
13 | class Elastica_Query_Ids extends Elastica_Query_Abstract
14 | {
15 | /**
16 | * Params
17 | *
18 | * @var array Params
19 | */
20 | protected $_params = array();
21 |
22 | /**
23 | * Creates filter object
24 | *
25 | * @param string|Elastica_Type $type Type to filter on
26 | * @param array $ids List of ids
27 | */
28 | public function __construct($type = null, array $ids = array())
29 | {
30 | $this->setType($type);
31 | $this->setIds($ids);
32 | }
33 |
34 | /**
35 | * Adds one more filter to the and filter
36 | *
37 | * @param string $id Adds id to filter
38 | * @return Elastica_Query_Ids Current object
39 | */
40 | public function addId($id)
41 | {
42 | $this->_params['values'][] = $id;
43 |
44 | return $this;
45 | }
46 |
47 | /**
48 | * Adds one more type to query
49 | *
50 | * @param string $type Adds type to query
51 | * @return Elastica_Query_Ids Current object
52 | */
53 | public function addType($type)
54 | {
55 | if ($type instanceof Elastica_Type) {
56 | $type = $type->getType();
57 | } elseif (empty($type) && !is_numeric($type)) {
58 | // A type can be 0, but cannot be empty
59 | return $this;
60 | }
61 |
62 | $this->_params['type'][] = $type;
63 |
64 | return $this;
65 | }
66 |
67 | /**
68 | * Set type
69 | *
70 | * @param string|Elastica_Type $type Type name or object
71 | * @return Elastica_Query_Ids Current object
72 | */
73 | public function setType($type)
74 | {
75 | if ($type instanceof Elastica_Type) {
76 | $type = $type->getType();
77 | } elseif (empty($type) && !is_numeric($type)) {
78 | // A type can be 0, but cannot be empty
79 | return $this;
80 | }
81 |
82 | $this->_params['type'] = $type;
83 |
84 | return $this;
85 | }
86 |
87 | /**
88 | * Sets the ids to filter
89 | *
90 | * @param array|string $ids List of ids
91 | * @return Elastica_Query_Ids Current object
92 | */
93 | public function setIds($ids)
94 | {
95 | if (is_array($ids)) {
96 | $this->_params['values'] = $ids;
97 | } else {
98 | $this->_params['values'] = array($ids);
99 | }
100 |
101 | return $this;
102 | }
103 |
104 | /**
105 | * Converts filter to array
106 | *
107 | * @see Elastica_Query_Abstract::toArray()
108 | * @return array Query array
109 | */
110 | public function toArray()
111 | {
112 | return array('ids' => $this->_params);
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # Welcome To OA's Elastica Search!
2 | 這是一個 Elastica Search 基本 CRUD 的使用工具,架構於 [Elastica Library](https://github.com/ruflin/Elastica),將讀取出來的資料物件化,以及包裝成方便開發的工具。
3 |
4 | ---
5 |
6 |
7 | ## 聲明
8 | 本作品授權採用 姓名標示-非商業性 2.0 台灣 (CC BY-NC 2.0 TW) 授權,詳見 [http://creativecommons.org/licenses/by-nc/2.0/tw/](http://creativecommons.org/licenses/by-nc/2.0/tw/)
9 |
10 |
11 |
12 |
13 | ## 詳細 DEMO 說明網頁
14 | * [https://works.ioa.tw/OA-ElasticaSearch/index.html](https://works.ioa.tw/OA-ElasticaSearch/index.html)
15 |
16 |
17 |
18 | ## 簡介
19 | * 這是一套架構於 [Elastica Library](https://github.com/ruflin/Elastica) 所開發的工具,進階方便使用物件操作 Elastica Search 資料讀取。
20 | * 經由各種類別方法(static),對 Elastica Search 實作 [新增](https://works.ioa.tw/OA-ElasticaSearch/guide/create.html)、[查詢](https://works.ioa.tw/OA-ElasticaSearch/guide/read.html)、[修改](https://works.ioa.tw/OA-ElasticaSearch/guide/update.html)、[刪除](https://works.ioa.tw/OA-ElasticaSearch/guide/delete.html) 的操作。
21 | * 查詢出來的每一筆資料,再將其封裝成物件單位,方便於物件化思維的設計。
22 | * 每筆物件皆可繼承基礎的 [修改](https://works.ioa.tw/OA-ElasticaSearch/guide/update.html)、[刪除](https://works.ioa.tw/OA-ElasticaSearch/guide/delete.html) 的實體方法。
23 | * 分別對不同 Type 分類出不同的類別(Class)。
24 | * 使用前要先引入 `demo/Elastica/ElasticaSearch.php` 檔案後即可使用。
25 | * CRUD 範例,將會以 Type User 作為範例說明,詳細結構可以查閱 [結構說明](https://works.ioa.tw/OA-ElasticaSearch/guide/struct.html)。
26 | * 後端 PHP 語言範例可以查閱檔案 `demo/index.php`。
27 | * 相關 Elastica Search 語法可以查閱 [https://www.elastic.co/](https://www.elastic.co/)。
28 |
29 |
30 |
31 |
32 |
33 | ## 目錄
34 | * [結構說明](https://works.ioa.tw/OA-ElasticaSearch/guide/struct.html)
35 | * [Mac 安裝](https://works.ioa.tw/OA-ElasticaSearch/guide/install.html)
36 | * [新增 (Create)](https://works.ioa.tw/OA-ElasticaSearch/guide/create.html)
37 | * [單筆新增 - create()](https://works.ioa.tw/OA-ElasticaSearch/guide/create.html#create)
38 | * [多筆新增 - createMany()](https://works.ioa.tw/OA-ElasticaSearch/guide/create.html#createMany)
39 | * [讀取 (Read)](https://works.ioa.tw/OA-ElasticaSearch/guide/read.html)
40 | * [單筆查詢 - find('one')](https://works.ioa.tw/OA-ElasticaSearch/guide/read.html#findOne)
41 | * [多筆查詢 - find('all')](https://works.ioa.tw/OA-ElasticaSearch/guide/read.html#findAll)
42 | * [多項條件查詢 - find('all', $conditions)](https://works.ioa.tw/OA-ElasticaSearch/guide/read.html#findConditions)
43 | * [更新 (Update)](https://works.ioa.tw/OA-ElasticaSearch/guide/update.html)
44 | * [物件資料更新 - save()](https://works.ioa.tw/OA-ElasticaSearch/guide/update.html#save)
45 | * [單筆資料更新 - update()](https://works.ioa.tw/OA-ElasticaSearch/guide/update.html#update)
46 | * [多筆資料更新 - updateMany()](https://works.ioa.tw/OA-ElasticaSearch/guide/update.html#updateMany)
47 | * [刪除 (Delete)](https://works.ioa.tw/OA-ElasticaSearch/guide/delete.html)
48 | * [物件資料刪除 - delete()](https://works.ioa.tw/OA-ElasticaSearch/guide/delete.html#delete)
49 | * [多筆刪除 - deleteMany()](https://works.ioa.tw/OA-ElasticaSearch/guide/delete.html#deleteMany)
50 |
51 |
52 |
53 |
54 | ### 關於
55 |
56 | * 作者名稱 - [OA Wu](http://www.ioa.tw/)
57 | * E-mail -
58 | * 作品名稱 - OA-ElasticaSearch
59 | * 最新版本 - 1.1
60 | * GitHub - [OA-ElasticaSearch](https://github.com/comdan66/OA-ElasticaSearch)
61 | * Reference - [Elastica Library](https://github.com/ruflin/Elastica)
62 | * Reference - [https://www.elastic.co/](https://www.elastic.co/)
63 | * 更新日期 - 2015/08/28
--------------------------------------------------------------------------------
/demo/Elastica/Exception/Client.php:
--------------------------------------------------------------------------------
1 |
8 | */
9 | class Elastica_Exception_Client extends Elastica_Exception_Abstract
10 | {
11 | /**
12 | * Error code / message
13 | *
14 | * @var string Error code / message
15 | */
16 | protected $_error = 0;
17 |
18 | /**
19 | * Request
20 | *
21 | * @var Elastica_Request Request object
22 | */
23 | protected $_request = null;
24 |
25 | /**
26 | * Response
27 | *
28 | * @var Elastica_Response Response object
29 | */
30 | protected $_response = null;
31 |
32 | /**
33 | * Construct Exception
34 | *
35 | * @param string $error Error
36 | * @param Elastica_Request $request
37 | * @param Elastica_Response $response
38 | */
39 | public function __construct($error, Elastica_Request $request = null, Elastica_Response $response = null)
40 | {
41 | $this->_error = $error;
42 | $this->_request = $request;
43 | $this->_response = $response;
44 |
45 | $message = $this->getErrorMessage($this->getError());
46 | parent::__construct($message);
47 | }
48 |
49 | /**
50 | * Returns the error message corresponding to the error code
51 | * cUrl error code reference can be found here {@link http://curl.haxx.se/libcurl/c/libcurl-errors.html}
52 | *
53 | * @param string $error Error code
54 | * @return string Error message
55 | */
56 | public function getErrorMessage($error)
57 | {
58 | switch ($error) {
59 | case CURLE_UNSUPPORTED_PROTOCOL:
60 | $error = "Unsupported protocol";
61 | break;
62 | case CURLE_FAILED_INIT:
63 | $error = "Internal cUrl error?";
64 | break;
65 | case CURLE_URL_MALFORMAT:
66 | $error = "Malformed URL";
67 | break;
68 | case CURLE_COULDNT_RESOLVE_PROXY:
69 | $error = "Couldnt resolve proxy";
70 | break;
71 | case CURLE_COULDNT_RESOLVE_HOST:
72 | $error = "Couldnt resolve host";
73 | break;
74 | case CURLE_COULDNT_CONNECT:
75 | $error = "Couldnt connect to host, ElasticSearch down?";
76 | break;
77 | case 28:
78 | $error = "Operation timed out";
79 | break;
80 | default:
81 | $error = "Unknown error:" . $error;
82 | break;
83 | }
84 |
85 | return $error;
86 | }
87 |
88 | /**
89 | * Return Error code / message
90 | *
91 | * @return string Error code / message
92 | */
93 | public function getError()
94 | {
95 | return $this->_error;
96 | }
97 |
98 | /**
99 | * Returns request object
100 | *
101 | * @return Elastica_Transport_Abstract Request object
102 | */
103 | public function getRequest()
104 | {
105 | return $this->_request;
106 | }
107 |
108 | /**
109 | * Returns response object
110 | *
111 | * @return Elastica_Response Response object
112 | */
113 | public function getResponse()
114 | {
115 | return $this->_response;
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/demo/Elastica/Facet/Terms.php:
--------------------------------------------------------------------------------
1 |
8 | * @author Jasper van Wanrooy
9 | * @link http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html
10 | */
11 | class Elastica_Facet_Terms extends Elastica_Facet_Abstract
12 | {
13 | /**
14 | * Holds the types of ordering which are allowed
15 | * by ElasticSearch.
16 | *
17 | * @var array
18 | */
19 | protected $_orderTypes = array('count', 'term', 'reverse_count', 'reverse_term');
20 |
21 | /**
22 | * Sets the field for the terms.
23 | *
24 | * @param string $field The field name for the terms.
25 | * @return Elastica_Facet_Terms
26 | */
27 | public function setField($field)
28 | {
29 | return $this->setParam('field', $field);
30 | }
31 |
32 | /**
33 | * Sets multiple fields for the terms.
34 | *
35 | * @param array $fields Numerical array with the fields for the terms.
36 | * @return Elastica_Facet_Terms
37 | */
38 | public function setFields(array $fields)
39 | {
40 | return $this->setParam('fields', $fields);
41 | }
42 |
43 | /**
44 | * Sets the flag to return all available terms. When they
45 | * don't have a hit, they have a count of zero.
46 | *
47 | * @param bool $allTerms Flag to fetch all terms.
48 | * @return Elastica_Facet_Terms
49 | */
50 | public function setAllTerms($allTerms)
51 | {
52 | return $this->setParam('all_terms', (bool) $allTerms);
53 | }
54 |
55 | /**
56 | * Sets the ordering type for this facet. ElasticSearch
57 | * internal default is count.
58 | *
59 | * @param string $type The order type to set use for sorting of the terms.
60 | * @throws Elastica_Exception_Invalid When an invalid order type was set.
61 | * @return Elastica_Facet_Terms
62 | */
63 | public function setOrder($type)
64 | {
65 | if (!in_array($type, $this->_orderTypes)) {
66 | throw new Elastica_Exception_Invalid('Invalid order type: ' . $type);
67 | }
68 |
69 | return $this->setParam('order', $type);
70 | }
71 |
72 | /**
73 | * Set an array with terms which are omitted in the search.
74 | *
75 | * @param array $exclude Numerical array which includes all terms which needs to be ignored.
76 | * @return Elastica_Facet_Terms
77 | */
78 | public function setExclude(array $exclude)
79 | {
80 | return $this->setParam('exclude', $exclude);
81 | }
82 |
83 | /**
84 | * Sets the amount of terms to be returned.
85 | *
86 | * @param int $size The amount of terms to be returned.
87 | * @return Elastica_Facet_Terms
88 | */
89 | public function setSize($size)
90 | {
91 | return $this->setParam('size', (int) $size);
92 | }
93 |
94 | /**
95 | * Creates the full facet definition, which includes the basic
96 | * facet definition of the parent.
97 | *
98 | * @see Elastica_Facet_Abstract::toArray()
99 | * @return array
100 | */
101 | public function toArray()
102 | {
103 | $this->_setFacetParam('terms', $this->_params);
104 |
105 | return parent::toArray();
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/demo/Elastica/Index/Status.php:
--------------------------------------------------------------------------------
1 |
8 | * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-status.html
9 | */
10 | class Elastica_Index_Status
11 | {
12 | /**
13 | * Response
14 | *
15 | * @var Elastica_Response Response object
16 | */
17 | protected $_response = null;
18 |
19 | /**
20 | * Stats info
21 | *
22 | * @var array Stats info
23 | */
24 | protected $_data = array();
25 |
26 | /**
27 | * Index
28 | *
29 | * @var Elastica_Index Index object
30 | */
31 | protected $_index = null;
32 |
33 | /**
34 | * Construct
35 | *
36 | * @param Elastica_Index $index Index object
37 | */
38 | public function __construct(Elastica_Index $index)
39 | {
40 | $this->_index = $index;
41 | $this->refresh();
42 | }
43 |
44 | /**
45 | * Returns all status info
46 | *
47 | * @return array Status info
48 | */
49 | public function getData()
50 | {
51 | return $this->_data;
52 | }
53 |
54 | /**
55 | * Returns the entry in the data array based on the params.
56 | * Various params possible.
57 | *
58 | * @return mixed Data array entry or null if not found
59 | */
60 | public function get()
61 | {
62 | $data = $this->getData();
63 | $data = $data['indices'][$this->getIndex()->getName()];
64 |
65 | foreach (func_get_args() as $arg) {
66 | if (isset($data[$arg])) {
67 | $data = $data[$arg];
68 | } else {
69 | return null;
70 | }
71 | }
72 |
73 | return $data;
74 | }
75 |
76 | /**
77 | * Returns all index aliases
78 | *
79 | * @return array Aliases
80 | */
81 | public function getAliases()
82 | {
83 | // TODO Update as soon as new API is implmented
84 | $cluster = new Elastica_Cluster($this->_index->getClient());
85 | $state = $cluster->getState();
86 |
87 | return $state['metadata']['indices'][$this->_index->getName()]['aliases'];
88 | }
89 |
90 | /**
91 | * Returns all index settings
92 | *
93 | * @return array Index settings
94 | */
95 | public function getSettings()
96 | {
97 | // TODO Update as soon as new API is implmented
98 | $cluster = new Elastica_Cluster($this->_index->getClient());
99 | $state = $cluster->getState();
100 |
101 | return $state['metadata']['indices'][$this->_index->getName()]['settings'];
102 | }
103 |
104 | /**
105 | * Checks if the index has the given alias
106 | *
107 | * @param string $name Alias name
108 | */
109 | public function hasAlias($name)
110 | {
111 | return in_array($name, $this->getAliases());
112 | }
113 |
114 | /**
115 | * Returns the index object
116 | *
117 | * @return Elastica_Index Index object
118 | */
119 | public function getIndex()
120 | {
121 | return $this->_index;
122 | }
123 |
124 | /**
125 | * Returns response object
126 | *
127 | * @return Elastica_Response Response object
128 | */
129 | public function getResponse()
130 | {
131 | return $this->_response;
132 | }
133 |
134 | /**
135 | * Reloads all status data of this object
136 | */
137 | public function refresh()
138 | {
139 | $path = '_status';
140 | $this->_response = $this->getIndex()->request($path, Elastica_Request::GET);
141 | $this->_data = $this->getResponse()->getData();
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/guide/cmd/imports/functions/_oa-load.scss:
--------------------------------------------------------------------------------
1 | /**
2 | * @author OA Wu
3 | * @copyright Copyright (c) 2016 OA Wu Design
4 | */
5 |
6 | @mixin loading ($dimension: 80px, $borderWidth: 4, $backgroundColor: rgba(39, 39, 34, .85)) {
7 | $offset: 187;
8 | $duration: 1.4s;
9 | display: inline-block;
10 | width: 100%;
11 | height: 100%;
12 | z-index: 9999999;
13 | background-color: $backgroundColor;
14 |
15 | &.hide {
16 | .svg {
17 | top: 50%;
18 | left: 50%;
19 | width: 0;
20 | height: 0;
21 | @include animation(loading_rotator $duration linear infinite, loading_hide .5s);
22 | }
23 | }
24 |
25 | .svg {
26 | position: absolute;
27 | top: calc(50% - #{$dimension / 2});
28 | left: calc(50% - #{$dimension / 2});
29 | width: $dimension;
30 | height: $dimension;
31 |
32 | @include animation(loading_rotator $duration linear infinite, loading_show .8s);
33 | @include transition(all 1s);
34 |
35 | .path {
36 | stroke-dasharray: $offset;
37 | stroke-dashoffset: 0;
38 | stroke-width: $borderWidth;
39 | @include transform-origin(center);
40 | @include animation(loading_dash $duration ease-in-out infinite, loading_colors ($duration * 4) ease-in-out infinite);
41 | }
42 | }
43 |
44 | @include keyframes(loading_hide){
45 | 0% {
46 | top: calc(50% - #{$dimension / 2});
47 | left: calc(50% - #{$dimension / 2});
48 | width: $dimension;
49 | height: $dimension;
50 | }
51 | 15% {
52 | $a: 0.8;
53 | top: calc(50% - #{($dimension * $a) / 2});
54 | left: calc(50% - #{($dimension * $a) / 2});
55 | width: $dimension * $a;
56 | height: $dimension * $a;
57 | }
58 | 30% {
59 | $a: 1.3;
60 | top: calc(50% - #{($dimension * $a) / 2});
61 | left: calc(50% - #{($dimension * $a) / 2});
62 | width: $dimension * $a;
63 | height: $dimension * $a;
64 | }
65 | 100% {
66 | top: 50%;
67 | left: 50%;
68 | width: 0;
69 | height: 0;
70 | }
71 | }
72 |
73 | @include keyframes(loading_show){
74 | 0% {
75 | top: 50%;
76 | left: 50%;
77 | width: 0;
78 | height: 0;
79 | }
80 | 30% {
81 | $a: 1.3;
82 | top: calc(50% - #{($dimension * $a) / 2});
83 | left: calc(50% - #{($dimension * $a) / 2});
84 | width: $dimension * $a;
85 | height: $dimension * $a;
86 | }
87 | 75% {
88 | $a: 0.8;
89 | top: calc(50% - #{($dimension * $a) / 2});
90 | left: calc(50% - #{($dimension * $a) / 2});
91 | width: $dimension * $a;
92 | height: $dimension * $a;
93 | }
94 | 100% {
95 | top: calc(50% - #{$dimension / 2});
96 | left: calc(50% - #{$dimension / 2});
97 | width: $dimension;
98 | height: $dimension;
99 | }
100 | }
101 | @include keyframes(loading_rotator){
102 | 0% { @include transform(rotate(0deg)); }
103 | 100% { @include transform(rotate(270deg)); }
104 | }
105 |
106 | @include keyframes(loading_colors){
107 | 0% { stroke: rgba(244, 67, 54, 1); }
108 | 20% { stroke: rgba(255, 152, 0, 1); }
109 | 40% { stroke: rgba(255, 235, 59, 1); }
110 | 60% { stroke: rgba(76, 175, 80, 1); }
111 | 80% { stroke: rgba(33, 150, 243, 1); }
112 | 100% { stroke: rgba(156, 39, 176, 1); }
113 | }
114 |
115 | @include keyframes(loading_dash){
116 | 0% {
117 | @include opacity(0);
118 | stroke-dashoffset: $offset;
119 | }
120 | 10% {
121 | @include opacity(1);
122 | }
123 | 50% {
124 | stroke-dashoffset: $offset/4;
125 | @include transform(rotate(135deg));
126 | }
127 | 90% {
128 | @include opacity(1);
129 | }
130 | 100% {
131 | @include opacity(0);
132 | stroke-dashoffset: $offset;
133 | @include transform(rotate(450deg));
134 | }
135 | }
136 | }
--------------------------------------------------------------------------------
/demo/Elastica/Facet/Abstract.php:
--------------------------------------------------------------------------------
1 |
8 | * @author Jasper van Wanrooy
9 | */
10 | abstract class Elastica_Facet_Abstract extends Elastica_Param
11 | {
12 | /**
13 | * Holds the name of the facet.
14 | * @var string
15 | */
16 | protected $_name = '';
17 |
18 | /**
19 | * Holds all facet parameters.
20 | * @var array
21 | */
22 | protected $_facet = array();
23 |
24 | /**
25 | * Constructs a Facet object.
26 | *
27 | * @param string $name The name of the facet.
28 | */
29 | public function __construct($name)
30 | {
31 | $this->setName($name);
32 | }
33 |
34 | /**
35 | * Sets the name of the facet. It is automatically set by
36 | * the constructor.
37 | *
38 | * @param string $name The name of the facet.
39 | * @throws Elastica_Exception_Invalid
40 | * @return Elastica_Facet_Abstract
41 | */
42 | public function setName($name)
43 | {
44 | if (empty($name)) {
45 | throw new Elastica_Exception_Invalid('Facet name has to be set');
46 | }
47 | $this->_name = $name;
48 |
49 | return $this;
50 | }
51 |
52 | /**
53 | * Gets the name of the facet.
54 | *
55 | * @return string
56 | */
57 | public function getName()
58 | {
59 | return $this->_name;
60 | }
61 |
62 | /**
63 | * Sets a filter for this facet.
64 | *
65 | * @param Elastica_Filter_Abstract $filter A filter to apply on the facet.
66 | * @return Elastica_Facet_Abstract
67 | */
68 | public function setFilter(Elastica_Filter_Abstract $filter)
69 | {
70 | return $this->_setFacetParam('facet_filter', $filter->toArray());
71 | }
72 |
73 | /**
74 | * Sets the flag to either run the facet globally or bound to the
75 | * current search query. When not set, it defaults to the
76 | * ElasticSearch default value.
77 | *
78 | * @param bool $global Flag to either run the facet globally.
79 | * @return Elastica_Facet_Abstract
80 | */
81 | public function setGlobal($global = true)
82 | {
83 | return $this->_setFacetParam('global', (bool) $global);
84 | }
85 |
86 | /**
87 | * Sets the path to the nested document
88 | *
89 | * @param string $nestedPath Nested path
90 | * @return Elastica_Facet_Abstract
91 | */
92 | public function setNested($nestedPath)
93 | {
94 | return $this->_setFacetParam('nested', $nestedPath);
95 | }
96 |
97 | /**
98 | * Sets the scope
99 | *
100 | * @param string $scope Scope
101 | * @return Elastica_Facet_Abstract
102 | */
103 | public function setScope($scope)
104 | {
105 | return $this->_setFacetParam('scope', $scope);
106 | }
107 |
108 | /**
109 | * Basic definition of all specs of the facet. Each implementation
110 | * should override this function in order to set it's specific
111 | * settings.
112 | *
113 | * @return array
114 | */
115 | public function toArray()
116 | {
117 | return $this->_facet;
118 | }
119 |
120 | /**
121 | * Sets a param for the facet. Each facet implementation needs to take
122 | * care of handling their own params.
123 | *
124 | * @param string $key The key of the param to set.
125 | * @param mixed $value The value of the param.
126 | * @return Elastica_Facet_Abstract
127 | */
128 | protected function _setFacetParam($key, $value)
129 | {
130 | $this->_facet[$key] = $value;
131 |
132 | return $this;
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/demo/Elastica/Util.php:
--------------------------------------------------------------------------------
1 |
8 | * @author Thibault Duplessis
9 | * @author Oleg Zinchenko
10 | */
11 | class Elastica_Util
12 | {
13 | /**
14 | * Replace the following reserved words: AND OR NOT
15 | * and
16 | * escapes the following terms: + - && || ! ( ) { } [ ] ^ " ~ * ? : \
17 | *
18 | * @param string $term Query term to replare and escape
19 | * @return string Replaced and escaped query term
20 | * @link http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Boolean%20operators
21 | * @link http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Escaping%20Special%20Characters
22 | */
23 | public static function replaceBooleanWordsAndEscapeTerm($term)
24 | {
25 | $result = $term;
26 | $result = self::replaceBooleanWords($result);
27 | $result = self::escapeTerm($result);
28 |
29 | return $result;
30 | }
31 |
32 | /**
33 | * Escapes the following terms (because part of the query language)
34 | * + - && || ! ( ) { } [ ] ^ " ~ * ? : \
35 | *
36 | * @param string $term Query term to escape
37 | * @return string Escaped query term
38 | * @link http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Escaping%20Special%20Characters
39 | */
40 | public static function escapeTerm($term)
41 | {
42 | $result = $term;
43 | // \ escaping has to be first, otherwise escaped later once again
44 | $chars = array('\\', '+', '-', '&&', '||', '!', '(', ')', '{', '}', '[', ']', '^', '"', '~', '*', '?', ':');
45 |
46 | foreach ($chars as $char) {
47 | $result = str_replace($char, '\\' . $char, $result);
48 | }
49 |
50 | return $result;
51 | }
52 |
53 | /**
54 | * Replace the following reserved words (because part of the query language)
55 | * AND OR NOT
56 | *
57 | * @param string $term Query term to replace
58 | * @return string Replaced query term
59 | * @link http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Boolean%20operators
60 | */
61 | public static function replaceBooleanWords($term)
62 | {
63 | $replacementMap = array('AND'=>'&&', 'OR'=>'||', 'NOT'=>'!');
64 | $result = strtr($term, $replacementMap);
65 |
66 | return $result;
67 | }
68 |
69 | /**
70 | * Converts a snake_case string to CamelCase
71 | *
72 | * For example: hello_world to HelloWorld
73 | *
74 | * @param string $string snake_case string
75 | * @return string CamelCase string
76 | */
77 | public static function toCamelCase($string)
78 | {
79 | return str_replace(" ", "", ucwords(str_replace("_", " ", $string)));
80 | }
81 |
82 | /**
83 | * Converts a CamelCase string to snake_case
84 | *
85 | * For Example HelloWorld to hello_world
86 | *
87 | * @param string $string CamelCase String to Convert
88 | * @return string SnakeCase string
89 | */
90 | public static function toSnakeCase($string)
91 | {
92 | $string = preg_replace('/([A-Z])/', '_$1', $string);
93 |
94 | return strtolower(substr($string,1));
95 | }
96 |
97 | /**
98 | * Converts given time to format: 1995-12-31T23:59:59Z
99 | *
100 | * This is the lucene date format
101 | *
102 | * @param int $date Date input (could be string etc.) -> must be supported by strtotime
103 | * @return string Converted date string
104 | */
105 | public static function convertDate($date)
106 | {
107 | if (is_int($date)) {
108 | $timestamp = $date;
109 | } else {
110 | $timestamp = strtotime($date);
111 | }
112 | $string = date('Y-m-d\TH:i:s\Z', $timestamp);
113 |
114 | return $string;
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/guide/delete.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 刪除 (Delete) - OA-ElasticaSearch
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 |
46 |
刪除 Delete
47 |
48 |
物件資料刪除
49 |
格式:$objext->delete();。
50 |
51 |
52 |
53 |
54 |
55 |
56 | // 藉由 id 等於 1
57 | $user = User::find('one', array(
58 | 'must' => array('id' => 1)
59 | ));
60 |
61 | // 刪除
62 | $user->delete();
63 |
64 |
65 |
66 |

67 |
68 |
69 |
70 |
71 |
72 |
多筆刪除
73 |
格式:Class::deleteMany($ids);。
74 |
75 | - $ids - 陣列,primary_key 欄位的陣列。
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 | $ids = array(1, 2, 3);
84 |
85 | // 依據 primary_key 欄位值陣列刪除
86 | User::deleteMany ($ids);
87 |
88 |
89 |
90 |

91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/demo/Elastica/Filter/Bool.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html
10 | */
11 | class Elastica_Filter_Bool extends Elastica_Filter_Abstract
12 | {
13 | /**
14 | * minimum number of matches
15 | *
16 | * @var int minimum number of matches
17 | */
18 | protected $_minimumNumberShouldMatch = 1;
19 |
20 | /**
21 | * Must
22 | *
23 | * @var array
24 | */
25 | protected $_must = array();
26 |
27 | /**
28 | * Should
29 | *
30 | * @var array
31 | */
32 | protected $_should = array();
33 |
34 | /**
35 | * Must not
36 | *
37 | * @var array
38 | */
39 | protected $_mustNot = array();
40 |
41 | /**
42 | * Adds should filter
43 | *
44 | * @param array|Elastica_Filter_Abstract $args Filter data
45 | * @return Elastica_Filter_Bool Current object
46 | */
47 | public function addShould($args)
48 | {
49 | return $this->_addFilter('should', $args);
50 | }
51 |
52 | /**
53 | * Adds must filter
54 | *
55 | * @param array|Elastica_Filter_Abstract $args Filter data
56 | * @return Elastica_Filter_Bool Current object
57 | */
58 | public function addMust($args)
59 | {
60 | return $this->_addFilter('must', $args);
61 | }
62 |
63 | /**
64 | * Adds mustNot filter
65 | *
66 | * @param array|Elastica_Filter_Abstract $args Filter data
67 | * @return Elastica_Filter_Bool Current object
68 | */
69 | public function addMustNot($args)
70 | {
71 | return $this->_addFilter('mustNot', $args);
72 | }
73 |
74 | /**
75 | * Adds general filter based on type
76 | *
77 | * @param string $type Filter type
78 | * @param array|Elastica_Filter_Abstract $args Filter data
79 | * @return Elastica_Filter_Bool Current object
80 | */
81 | protected function _addFilter($type, $args)
82 | {
83 | if ($args instanceof Elastica_Filter_Abstract) {
84 | $args = $args->toArray();
85 | }
86 |
87 | if (!is_array($args)) {
88 | throw new Elastica_Exception_Invalid('Invalid parameter. Has to be array or instance of Elastica_Filter');
89 | }
90 |
91 | $varName = '_' . $type;
92 | $this->{$varName}[] = $args;
93 |
94 | return $this;
95 | }
96 |
97 | /**
98 | * Converts bool filter to array
99 | *
100 | * @see Elastica_Filter_Abstract::toArray()
101 | * @return array Filter array
102 | */
103 | public function toArray()
104 | {
105 | $args = array();
106 |
107 | if (!empty($this->_must)) {
108 | $args['must'] = $this->_must;
109 | }
110 |
111 | if (!empty($this->_should)) {
112 | $args['should'] = $this->_should;
113 | }
114 |
115 | if (!empty($this->_mustNot)) {
116 | $args['must_not'] = $this->_mustNot;
117 | }
118 |
119 | return array('bool' => $args);
120 | }
121 |
122 | /**
123 | * Sets the boost value for this filter
124 | *
125 | * @param float $boost Boost
126 | * @return Elastica_Filter_Bool Current object
127 | */
128 | public function setBoost($boost)
129 | {
130 | $this->_boost = $boost;
131 |
132 | return $this;
133 | }
134 |
135 | /**
136 | * Sets the minimum number that should filter have to match
137 | *
138 | * @param int $minimumNumberShouldMatch Number of matches
139 | * @return Elastica_Filter_Bool Current object
140 | */
141 | public function setMinimumNumberShouldMatch($minimumNumberShouldMatch)
142 | {
143 | $this->_minimumNumberShouldMatch = intval($minimumNumberShouldMatch);
144 |
145 | return $this;
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/demo/Elastica/Param.php:
--------------------------------------------------------------------------------
1 |
10 | */
11 | class Elastica_Param
12 | {
13 | /**
14 | * Params
15 | *
16 | * @var array
17 | */
18 | protected $_params = array();
19 |
20 | /**
21 | * Raw Params
22 | *
23 | * @var array
24 | */
25 | protected $_rawParams = array();
26 |
27 | /**
28 | * Converts the params to an array. A default implementation exist to create
29 | * the an array out of the class name (last part of the class name)
30 | * and the params
31 | *
32 | * @return array Filter array
33 | */
34 | public function toArray()
35 | {
36 | $data = array($this->_getBaseName() => $this->getParams());
37 |
38 | if (!empty($this->_rawParams)) {
39 | $data = array_merge($data, $this->_rawParams);
40 | }
41 |
42 | return $data;
43 | }
44 |
45 | /**
46 | * Param's name
47 | * Picks the last part of the class name and makes it snake_case
48 | * You can override this method if you want to change the name
49 | *
50 | * @return string name
51 | */
52 | protected function _getBaseName()
53 | {
54 | $classNameParts = explode('_', get_class($this));
55 | $name = Elastica_Util::toSnakeCase(array_pop($classNameParts));
56 |
57 | return $name;
58 | }
59 |
60 | /**
61 | * Sets params not inside params array
62 | *
63 | * @param string $key
64 | * @param mixed $value
65 | * @return Elastica_Param
66 | */
67 | protected function _setRawParam($key, $value)
68 | {
69 | $this->_rawParams[$key] = $value;
70 |
71 | return $this;
72 | }
73 |
74 | /**
75 | * Sets (overwrites) the value at the given key
76 | *
77 | * @param string $key Key to set
78 | * @param mixed $value Key Value
79 | */
80 | public function setParam($key, $value)
81 | {
82 | $this->_params[$key] = $value;
83 |
84 | return $this;
85 | }
86 |
87 | /**
88 | * Sets (overwrites) all params of this object
89 | *
90 | * @param array $params Parameter list
91 | * @return Elastica_Param
92 | */
93 | public function setParams(array $params)
94 | {
95 | $this->_params = $params;
96 |
97 | return $this;
98 | }
99 |
100 | /**
101 | * Adds a param to the list
102 | *
103 | * This function can be used to add an array of params
104 | *
105 | * @param string $key Param key
106 | * @param mixed $value Value to set
107 | * @return Elastica_Param
108 | */
109 | public function addParam($key, $value)
110 | {
111 | if (!isset($this->_params[$key])) {
112 | $this->_params[$key] = array();
113 | }
114 |
115 | $this->_params[$key][] = $value;
116 |
117 | return $this;
118 | }
119 |
120 | /**
121 | * Returns a specific param
122 | *
123 | * @param string $key Key to return
124 | * @return mixed Key value
125 | * @throws Elastica_Exception_Invalid If requested key is not set
126 | */
127 | public function getParam($key)
128 | {
129 | if (!isset($this->_params[$key])) {
130 | throw new Elastica_Exception_Invalid('Param ' . $key . ' does not exist');
131 | }
132 |
133 | return $this->_params[$key];
134 | }
135 |
136 | /**
137 | * Test if a param is set
138 | *
139 | * @param string $key Key to test
140 | * @return boolean True if the param is set, false otherwise
141 | */
142 | public function hasParam($key)
143 | {
144 | return isset($this->_params[$key]);
145 | }
146 |
147 | /**
148 | * Returns the params array
149 | *
150 | * @return array Params
151 | */
152 | public function getParams()
153 | {
154 | return $this->_params;
155 | }
156 | }
157 |
--------------------------------------------------------------------------------
/demo/Elastica/Query/FuzzyLikeThis.php:
--------------------------------------------------------------------------------
1 |
9 | * @link http://www.elasticsearch.org/guide/reference/query-dsl/flt-query.html
10 | */
11 | class Elastica_Query_FuzzyLikeThis extends Elastica_Query_Abstract
12 | {
13 | /**
14 | * Field names
15 | *
16 | * @var array Field names
17 | */
18 | protected $_fields = array();
19 |
20 | /**
21 | * Like text
22 | *
23 | * @var string Like text
24 | */
25 | protected $_likeText = '';
26 |
27 | /**
28 | * Max query terms value
29 | *
30 | * @var int Max query terms value
31 | */
32 | protected $_maxQueryTerms = 25;
33 |
34 | /**
35 | * minimum similarity
36 | *
37 | * @var int minimum similarity
38 | */
39 | protected $_minSimilarity = 0.5;
40 |
41 | /**
42 | * Prefix Length
43 | *
44 | * @var int Prefix Length
45 | */
46 | protected $_prefixLength = 0;
47 |
48 | /**
49 | * Boost
50 | *
51 | * @var float Boost
52 | */
53 | protected $_boost = 1.0;
54 |
55 | /**
56 | * Adds field to flt query
57 | *
58 | * @param array $fields Field names
59 | * @return Elastica_Query_FuzzyLikeThis Current object
60 | */
61 | public function addFields(array $fields)
62 | {
63 | $this->_fields = $fields;
64 |
65 | return $this;
66 | }
67 |
68 | /**
69 | * Set the "like_text" value
70 | *
71 | * @param string $text
72 | * @return Elastica_Query_FuzzyLikeThis This current object
73 | */
74 | public function setLikeText($text)
75 | {
76 | $text = trim($text);
77 | $this->_likeText = $text;
78 |
79 | return $this;
80 | }
81 |
82 | /**
83 | * Set the minimum similarity
84 | *
85 | * @param int $value
86 | * @return Elastica_Query_FuzzyLikeThis This current object
87 | */
88 | public function setMinSimilarity($value)
89 | {
90 | $value = (float) $value;
91 | $this->_minSimilarity = $value;
92 |
93 | return $this;
94 | }
95 |
96 | /**
97 | * Set boost
98 | *
99 | * @param float $value Boost value
100 | * @return Elastica_Query_FuzzyLikeThis Query object
101 | */
102 | public function setBoost($value)
103 | {
104 | $this->_boost = (float) $value;
105 |
106 | return $this;
107 | }
108 |
109 | /**
110 | * Set Prefix Length
111 | *
112 | * @param int $value Prefix length
113 | * @return Elastica_Query_FuzzyLikeThis
114 | */
115 | public function setPrefixLength($value)
116 | {
117 | $this->_prefixLength = (int) $value;
118 |
119 | return $this;
120 | }
121 |
122 | /**
123 | * Set max_query_terms
124 | *
125 | * @param int $value Max query terms value
126 | * @return Elastica_Query_FuzzyLikeThis
127 | */
128 | public function setMaxQueryTerms($value)
129 | {
130 | $this->_maxQueryTerms = (int) $value;
131 |
132 | return $this;
133 | }
134 |
135 | /**
136 | * Converts fuzzy like this query to array
137 | *
138 | * @return array Query array
139 | * @see Elastica_Query_Abstract::toArray()
140 | */
141 | public function toArray()
142 | {
143 | if (!empty($this->_fields)) {
144 | $args['fields'] = $this->_fields;
145 | }
146 |
147 | if (!empty($this->_boost)) {
148 | $args['boost'] = $this->_boost;
149 | }
150 |
151 | if (!empty($this->_likeText)) {
152 | $args['like_text'] = $this->_likeText;
153 | }
154 |
155 | $args['min_similarity'] = ($this->_minSimilarity > 0) ? $this->_minSimilarity : 0;
156 |
157 | $args['prefix_length'] = $this->_prefixLength;
158 | $args['max_query_terms'] = $this->_maxQueryTerms;
159 |
160 | return array('fuzzy_like_this' => $args);
161 | }
162 | }
163 |
--------------------------------------------------------------------------------
/guide/cmd/libs/functions.php:
--------------------------------------------------------------------------------
1 |
5 | * @copyright Copyright (c) 2016 OA Wu Design
6 | */
7 |
8 | if (!function_exists ('color')) {
9 | function color ($string, $foreground_color = null, $background_color = null, $is_print = false) {
10 | if (!strlen ($string)) return "";
11 | $colored_string = "";
12 | $keys = array ('n' => '30', 'w' => '37', 'b' => '34', 'g' => '32', 'c' => '36', 'r' => '31', 'p' => '35', 'y' => '33');
13 | if ($foreground_color && in_array (strtolower ($foreground_color), array_map ('strtolower', array_keys ($keys)))) {
14 | $foreground_color = !in_array (ord ($foreground_color[0]), array_map ('ord', array_keys ($keys))) ? in_array (ord ($foreground_color[0]) | 0x20, array_map ('ord', array_keys ($keys))) ? '1;' . $keys[strtolower ($foreground_color[0])] : null : $keys[$foreground_color[0]];
15 | $colored_string .= $foreground_color ? "\033[" . $foreground_color . "m" : "";
16 | }
17 | $colored_string .= $background_color && in_array (strtolower ($background_color), array_map ('strtolower', array_keys ($keys))) ? "\033[" . ($keys[strtolower ($background_color[0])] + 10) . "m" : "";
18 |
19 | if (substr ($string, -1) == "\n") { $string = substr ($string, 0, -1); $has_new_line = true; } else { $has_new_line = false; }
20 | $colored_string .= $string . "\033[0m";
21 | $colored_string = $colored_string . ($has_new_line ? "\n" : "");
22 | if ($is_print) printf ($colored_string);
23 | return $colored_string;
24 | }
25 | }
26 |
27 | if (!function_exists ('merge_array_recursive')) {
28 | function merge_array_recursive ($files, &$a, $k = null) {
29 | foreach ($files as $key => $file)
30 | if (is_array ($file)) $key . merge_array_recursive ($file, $a, ($k ? $k . DIRECTORY_SEPARATOR : '') . $key);
31 | else array_push ($a, ($k ? $k . DIRECTORY_SEPARATOR : '') . $file);
32 | }
33 | }
34 |
35 | if (!function_exists ('directory_list')) {
36 | function directory_list ($source_dir, $hidden = false) {
37 | if ($fp = @opendir ($source_dir = rtrim ($source_dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR)) {
38 | $filedata = array ();
39 |
40 | while (false !== ($file = readdir ($fp)))
41 | if (!(!trim ($file, '.') || (($hidden == false) && ($file[0] == '.'))))
42 | array_push($filedata, $file);
43 |
44 | closedir ($fp);
45 | return $filedata;
46 | }
47 | return array ();
48 | }
49 | }
50 |
51 | if (!function_exists ('params')) {
52 | function params ($params, $keys) {
53 | $ks = $return = $result = array ();
54 |
55 | if (!$params) return $return;
56 | if (!$keys) return $return;
57 |
58 | foreach ($keys as $key)
59 | if (is_array ($key)) foreach ($key as $k) array_push ($ks, $k);
60 | else array_push ($ks, $key);
61 |
62 | $key = null;
63 |
64 | foreach ($params as $param)
65 | if (in_array ($param, $ks)) if (!isset ($result[$key = $param])) $result[$key] = array (); else ;
66 | else if (isset ($result[$key])) array_push ($result[$key], $param); else ;
67 |
68 | foreach ($keys as $key)
69 | if (is_array ($key)) foreach ($key as $k) if (isset ($result[$k])) $return[$key[0]] = isset ($return[$key[0]]) ? array_merge ($return[$key[0]], $result[$k]) : $result[$k]; else;
70 | else if (isset ($result[$key])) $return[$key] = isset ($return[$key]) ? array_merge ($return[$key], $result[$key]) : $result[$key]; else;
71 |
72 | return $return;
73 | }
74 | }
75 |
76 | if (!function_exists ('directory_map')) {
77 | function directory_map ($source_dir, $directory_depth = 0, $hidden = false) {
78 | if ($fp = @opendir ($source_dir)) {
79 | $filedata = array ();
80 | $new_depth = $directory_depth - 1;
81 | $source_dir = rtrim ($source_dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
82 |
83 | while (false !== ($file = readdir ($fp))) {
84 | if (!trim ($file, '.') || (($hidden == false) && ($file[0] == '.')))
85 | continue;
86 |
87 | if ((($directory_depth < 1) || ($new_depth > 0)) && @is_dir ($source_dir . $file))
88 | $filedata[$file] = directory_map ($source_dir . $file . DIRECTORY_SEPARATOR, $new_depth, $hidden);
89 | else
90 | array_push ($filedata, $file);
91 | }
92 |
93 | closedir ($fp);
94 | return $filedata;
95 | }
96 |
97 | return false;
98 | }
99 | }
--------------------------------------------------------------------------------
/demo/Elastica/Node/Info.php:
--------------------------------------------------------------------------------
1 |
8 | * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-status.html
9 | */
10 | class Elastica_Node_Info
11 | {
12 | /**
13 | * Response
14 | *
15 | * @var Elastica_Response Response object
16 | */
17 | protected $_response = null;
18 |
19 | /**
20 | * Stats data
21 | *
22 | * @var array stats data
23 | */
24 | protected $_data = array();
25 |
26 | /**
27 | * Node
28 | *
29 | * @var Elastica_Node Node object
30 | */
31 | protected $_node = null;
32 |
33 | /**
34 | * Create new info object for node
35 | *
36 | * @param Elastica_Node $node Node object
37 | * @param array $params List of params to return. Can be: settings, os, process, jvm, thread_pool, network, transport, http
38 | */
39 | public function __construct(Elastica_Node $node, array $params = array())
40 | {
41 | $this->_node = $node;
42 | $this->refresh($params);
43 | }
44 |
45 | /**
46 | * Returns the entry in the data array based on the params.
47 | * Several params possible.
48 | *
49 | * Example 1: get('os', 'mem', 'total') returns total memory of the system the
50 | * node is running on
51 | * Example 2: get('os', 'mem') returns an array with all mem infos
52 | *
53 | * @return mixed Data array entry or null if not found
54 | */
55 | public function get()
56 | {
57 | $data = $this->getData();
58 |
59 | foreach (func_get_args() as $arg) {
60 | if (isset($data[$arg])) {
61 | $data = $data[$arg];
62 | } else {
63 | return null;
64 | }
65 | }
66 |
67 | return $data;
68 | }
69 |
70 | /**
71 | * Return port of the node
72 | *
73 | * @return string Returns Node port
74 | */
75 | public function getPort()
76 | {
77 | // Returns string in format: inet[/192.168.1.115:9201]
78 | $data = $this->get('http_address');
79 | $data = substr($data, 6, strlen($data) - 7);
80 | $data = explode(':', $data);
81 |
82 | return $data[1];
83 | }
84 |
85 | /**
86 | * Return IP of the node
87 | *
88 | * @return string Returns Node ip address
89 | */
90 | public function getIp()
91 | {
92 | // Returns string in format: inet[/192.168.1.115:9201]
93 | $data = $this->get('http_address');
94 | $data = substr($data, 6, strlen($data) - 7);
95 | $data = explode(':', $data);
96 |
97 | return $data[0];
98 | }
99 |
100 | /**
101 | * Return all info data
102 | *
103 | * @return array Data array
104 | */
105 | public function getData()
106 | {
107 | return $this->_data;
108 | }
109 |
110 | /**
111 | * Return node object
112 | *
113 | * @return Elastica_Node Node object
114 | */
115 | public function getNode()
116 | {
117 | return $this->_node;
118 | }
119 |
120 | /**
121 | * Returns response object
122 | *
123 | * @return Elastica_Response Response object
124 | */
125 | public function getResponse()
126 | {
127 | return $this->_response;
128 | }
129 |
130 | /**
131 | * Reloads all nodes information. Has to be called if informations changed
132 | *
133 | * @param array $params Params to return (default none). Possible options: settings, os, process, jvm, thread_pool, network, transport, http
134 | * @return Elastica_Response Response object
135 | */
136 | public function refresh(array $params = array())
137 | {
138 | $path = '_cluster/nodes/' . $this->getNode()->getName();
139 |
140 | if (!empty($params)) {
141 | $path .= '?';
142 | foreach ($params as $param) {
143 | $path .= $param . '=true&';
144 | }
145 | }
146 |
147 | $this->_response = $this->getNode()->getClient()->request($path, Elastica_Request::GET);
148 | $data = $this->getResponse()->getData();
149 | $this->_data = reset($data['nodes']);
150 | }
151 | }
152 |
--------------------------------------------------------------------------------