elasticsearch_query_parser 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +27 -0
  3. data/README.md +196 -0
  4. data/lib/doc/ElasticsearchQueryParser/Grammar/Parser.html +108 -0
  5. data/lib/doc/ElasticsearchQueryParser/Grammar/Presenters/Operator/InvalidOperatorString.html +206 -0
  6. data/lib/doc/ElasticsearchQueryParser/Grammar/Presenters/Operator.html +209 -0
  7. data/lib/doc/ElasticsearchQueryParser/Grammar/Presenters/Query.html +208 -0
  8. data/lib/doc/ElasticsearchQueryParser/Grammar/Presenters/Term.html +203 -0
  9. data/lib/doc/ElasticsearchQueryParser/Grammar/Presenters.html +99 -0
  10. data/lib/doc/ElasticsearchQueryParser/Grammar/Transformer.html +108 -0
  11. data/lib/doc/ElasticsearchQueryParser/Grammar.html +99 -0
  12. data/lib/doc/ElasticsearchQueryParser/ParseFailedException.html +163 -0
  13. data/lib/doc/ElasticsearchQueryParser/Sentence.html +219 -0
  14. data/lib/doc/ElasticsearchQueryParser.html +238 -0
  15. data/lib/doc/created.rid +8 -0
  16. data/lib/doc/css/fonts.css +167 -0
  17. data/lib/doc/css/rdoc.css +619 -0
  18. data/lib/doc/fonts/Lato-Light.ttf +0 -0
  19. data/lib/doc/fonts/Lato-LightItalic.ttf +0 -0
  20. data/lib/doc/fonts/Lato-Regular.ttf +0 -0
  21. data/lib/doc/fonts/Lato-RegularItalic.ttf +0 -0
  22. data/lib/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  23. data/lib/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  24. data/lib/doc/images/add.png +0 -0
  25. data/lib/doc/images/arrow_up.png +0 -0
  26. data/lib/doc/images/brick.png +0 -0
  27. data/lib/doc/images/brick_link.png +0 -0
  28. data/lib/doc/images/bug.png +0 -0
  29. data/lib/doc/images/bullet_black.png +0 -0
  30. data/lib/doc/images/bullet_toggle_minus.png +0 -0
  31. data/lib/doc/images/bullet_toggle_plus.png +0 -0
  32. data/lib/doc/images/date.png +0 -0
  33. data/lib/doc/images/delete.png +0 -0
  34. data/lib/doc/images/find.png +0 -0
  35. data/lib/doc/images/loadingAnimation.gif +0 -0
  36. data/lib/doc/images/macFFBgHack.png +0 -0
  37. data/lib/doc/images/package.png +0 -0
  38. data/lib/doc/images/page_green.png +0 -0
  39. data/lib/doc/images/page_white_text.png +0 -0
  40. data/lib/doc/images/page_white_width.png +0 -0
  41. data/lib/doc/images/plugin.png +0 -0
  42. data/lib/doc/images/ruby.png +0 -0
  43. data/lib/doc/images/tag_blue.png +0 -0
  44. data/lib/doc/images/tag_green.png +0 -0
  45. data/lib/doc/images/transparent.png +0 -0
  46. data/lib/doc/images/wrench.png +0 -0
  47. data/lib/doc/images/wrench_orange.png +0 -0
  48. data/lib/doc/images/zoom.png +0 -0
  49. data/lib/doc/index.html +107 -0
  50. data/lib/doc/js/darkfish.js +84 -0
  51. data/lib/doc/js/navigation.js +105 -0
  52. data/lib/doc/js/navigation.js.gz +0 -0
  53. data/lib/doc/js/search.js +110 -0
  54. data/lib/doc/js/search_index.js +1 -0
  55. data/lib/doc/js/search_index.js.gz +0 -0
  56. data/lib/doc/js/searcher.js +229 -0
  57. data/lib/doc/js/searcher.js.gz +0 -0
  58. data/lib/doc/table_of_contents.html +175 -0
  59. data/lib/elasticsearch_query_parser/grammar/parser.rb +29 -0
  60. data/lib/elasticsearch_query_parser/grammar/presenters/operator.rb +41 -0
  61. data/lib/elasticsearch_query_parser/grammar/presenters/query.rb +45 -0
  62. data/lib/elasticsearch_query_parser/grammar/presenters/term.rb +21 -0
  63. data/lib/elasticsearch_query_parser/grammar/transformer.rb +37 -0
  64. data/lib/elasticsearch_query_parser/sentence.rb +55 -0
  65. data/lib/elasticsearch_query_parser.rb +52 -0
  66. metadata +135 -0
@@ -0,0 +1,238 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>module ElasticsearchQueryParser - RDoc Documentation</title>
8
+
9
+ <script type="text/javascript">
10
+ var rdoc_rel_prefix = "./";
11
+ var index_rel_prefix = "./";
12
+ </script>
13
+
14
+ <script src="./js/navigation.js" defer></script>
15
+ <script src="./js/search.js" defer></script>
16
+ <script src="./js/search_index.js" defer></script>
17
+ <script src="./js/searcher.js" defer></script>
18
+ <script src="./js/darkfish.js" defer></script>
19
+
20
+ <link href="./css/fonts.css" rel="stylesheet">
21
+ <link href="./css/rdoc.css" rel="stylesheet">
22
+
23
+
24
+
25
+
26
+ <body id="top" role="document" class="module">
27
+ <nav role="navigation">
28
+ <div id="project-navigation">
29
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
30
+ <h2>
31
+ <a href="./index.html" rel="home">Home</a>
32
+ </h2>
33
+
34
+ <div id="table-of-contents-navigation">
35
+ <a href="./table_of_contents.html#pages">Pages</a>
36
+ <a href="./table_of_contents.html#classes">Classes</a>
37
+ <a href="./table_of_contents.html#methods">Methods</a>
38
+ </div>
39
+ </div>
40
+
41
+ <div id="search-section" role="search" class="project-section initially-hidden">
42
+ <form action="#" method="get" accept-charset="utf-8">
43
+ <div id="search-field-wrapper">
44
+ <input id="search-field" role="combobox" aria-label="Search"
45
+ aria-autocomplete="list" aria-controls="search-results"
46
+ type="text" name="search" placeholder="Search" spellcheck="false"
47
+ title="Type to search, Up and Down to navigate, Enter to load">
48
+ </div>
49
+
50
+ <ul id="search-results" aria-label="Search Results"
51
+ aria-busy="false" aria-expanded="false"
52
+ aria-atomic="false" class="initially-hidden"></ul>
53
+ </form>
54
+ </div>
55
+
56
+ </div>
57
+
58
+
59
+
60
+ <div id="class-metadata">
61
+
62
+
63
+
64
+
65
+ <!-- Method Quickref -->
66
+ <div id="method-list-section" class="nav-section">
67
+ <h3>Methods</h3>
68
+
69
+ <ul class="link-list" role="directory">
70
+
71
+ <li ><a href="#method-c-configuration">::configuration</a>
72
+
73
+ <li ><a href="#method-c-configure">::configure</a>
74
+
75
+ <li ><a href="#method-c-parse_query">::parse_query</a>
76
+
77
+ </ul>
78
+ </div>
79
+
80
+ </div>
81
+ </nav>
82
+
83
+ <main role="main" aria-labelledby="module-ElasticsearchQueryParser">
84
+ <h1 id="module-ElasticsearchQueryParser" class="module">
85
+ module ElasticsearchQueryParser
86
+ </h1>
87
+
88
+ <section class="description">
89
+
90
+ <p>Mail <a href="ElasticsearchQueryParser.html"><code>ElasticsearchQueryParser</code></a> interface</p>
91
+
92
+ </section>
93
+
94
+
95
+ <section id="5Buntitled-5D" class="documentation-section">
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+ <section id="public-class-5Buntitled-5D-method-details" class="method-section">
106
+ <header>
107
+ <h3>Public Class Methods</h3>
108
+ </header>
109
+
110
+
111
+ <div id="method-c-configuration" class="method-detail ">
112
+
113
+ <div class="method-heading">
114
+ <span class="method-name">configuration</span><span
115
+ class="method-args">()</span>
116
+
117
+ <span class="method-click-advice">click to toggle source</span>
118
+
119
+ </div>
120
+
121
+
122
+ <div class="method-description">
123
+
124
+ <p>Gem configuration object For now only contain 1 attribute: `elastic_field_name` option (by default :text) Responds with OpenStruct entity which responds_to `elastic_field_name` Example:</p>
125
+
126
+ <pre>&gt;&gt; ElasticsearchQueryParser.configuration
127
+ =&gt; #&lt;OpenStruct elastic_field_name=:text&gt;</pre>
128
+
129
+
130
+
131
+
132
+ <div class="method-source-code" id="configuration-source">
133
+ <pre><span class="ruby-comment"># File elasticsearch_query_parser.rb, line 15</span>
134
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">configuration</span>
135
+ <span class="ruby-ivar">@configuration</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">OpenStruct</span>.<span class="ruby-identifier">new</span>(
136
+ <span class="ruby-value">elastic_field_name:</span> <span class="ruby-value">:text</span>
137
+ )
138
+ <span class="ruby-keyword">end</span></pre>
139
+ </div>
140
+
141
+ </div>
142
+
143
+
144
+
145
+
146
+ </div>
147
+
148
+
149
+ <div id="method-c-configure" class="method-detail ">
150
+
151
+ <div class="method-heading">
152
+ <span class="method-name">configure</span><span
153
+ class="method-args">() { |configuration| ... }</span>
154
+
155
+ <span class="method-click-advice">click to toggle source</span>
156
+
157
+ </div>
158
+
159
+
160
+ <div class="method-description">
161
+
162
+ <p>For gem configuration For now only `elastic_field_name` can be modified. See README.md for details</p>
163
+
164
+
165
+
166
+
167
+ <div class="method-source-code" id="configure-source">
168
+ <pre><span class="ruby-comment"># File elasticsearch_query_parser.rb, line 23</span>
169
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">configure</span>
170
+ <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">configuration</span>)
171
+ <span class="ruby-keyword">end</span></pre>
172
+ </div>
173
+
174
+ </div>
175
+
176
+
177
+
178
+
179
+ </div>
180
+
181
+
182
+ <div id="method-c-parse_query" class="method-detail ">
183
+
184
+ <div class="method-heading">
185
+ <span class="method-name">parse_query</span><span
186
+ class="method-args">(user_query)</span>
187
+
188
+ <span class="method-click-advice">click to toggle source</span>
189
+
190
+ </div>
191
+
192
+
193
+ <div class="method-description">
194
+
195
+ <p>Parse given string into Elastic query object (see README.md for more examples) Example:</p>
196
+
197
+ <pre>&gt;&gt; ElasticsearchQueryParser.parse_query(&quot;London&quot;)
198
+ =&gt; { query: { bool: { should: [{ match: { text: { query: &quot;London&quot;, operator: &quot;and&quot; } } }] } } }</pre>
199
+
200
+
201
+
202
+
203
+ <div class="method-source-code" id="parse_query-source">
204
+ <pre><span class="ruby-comment"># File elasticsearch_query_parser.rb, line 31</span>
205
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">parse_query</span>(<span class="ruby-identifier">user_query</span>)
206
+ <span class="ruby-identifier">query</span> = <span class="ruby-constant">Sentence</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">user_query</span>).<span class="ruby-identifier">to_s</span>
207
+
208
+ <span class="ruby-keyword">return</span> {} <span class="ruby-keyword">if</span> <span class="ruby-identifier">query</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">empty?</span>
209
+
210
+ <span class="ruby-identifier">parse_tree</span> = <span class="ruby-constant">Grammar</span><span class="ruby-operator">::</span><span class="ruby-constant">Parser</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">query</span>)
211
+ <span class="ruby-identifier">transformed_query</span> = <span class="ruby-constant">Grammar</span><span class="ruby-operator">::</span><span class="ruby-constant">Transformer</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">apply</span>(<span class="ruby-identifier">parse_tree</span>)
212
+ { <span class="ruby-value">query:</span> <span class="ruby-identifier">transformed_query</span>.<span class="ruby-identifier">to_elasticsearch</span> }
213
+ <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Parslet</span><span class="ruby-operator">::</span><span class="ruby-constant">ParseFailed</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">e</span>
214
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">ParseFailedException</span>, <span class="ruby-identifier">e</span>.<span class="ruby-identifier">parse_failure_cause</span>
215
+ <span class="ruby-keyword">end</span></pre>
216
+ </div>
217
+
218
+ </div>
219
+
220
+
221
+
222
+
223
+ </div>
224
+
225
+
226
+ </section>
227
+
228
+ </section>
229
+
230
+ </main>
231
+
232
+
233
+ <footer id="validator-badges" role="contentinfo">
234
+ <p><a href="https://validator.w3.org/check/referer">Validate</a>
235
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.0.
236
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
237
+ </footer>
238
+
@@ -0,0 +1,8 @@
1
+ Sat, 25 Jul 2020 17:12:55 +0300
2
+ ./elasticsearch_query_parser/sentence.rb Sat, 25 Jul 2020 17:11:23 +0300
3
+ ./elasticsearch_query_parser/grammar/presenters/term.rb Sat, 25 Jul 2020 15:45:38 +0300
4
+ ./elasticsearch_query_parser/grammar/presenters/operator.rb Sat, 25 Jul 2020 15:45:38 +0300
5
+ ./elasticsearch_query_parser/grammar/presenters/query.rb Sat, 25 Jul 2020 15:45:38 +0300
6
+ ./elasticsearch_query_parser/grammar/parser.rb Sat, 25 Jul 2020 17:11:58 +0300
7
+ ./elasticsearch_query_parser/grammar/transformer.rb Sat, 25 Jul 2020 17:11:07 +0300
8
+ ./elasticsearch_query_parser.rb Sat, 25 Jul 2020 17:02:39 +0300
@@ -0,0 +1,167 @@
1
+ /*
2
+ * Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/),
3
+ * with Reserved Font Name "Source". All Rights Reserved. Source is a
4
+ * trademark of Adobe Systems Incorporated in the United States and/or other
5
+ * countries.
6
+ *
7
+ * This Font Software is licensed under the SIL Open Font License, Version
8
+ * 1.1.
9
+ *
10
+ * This license is copied below, and is also available with a FAQ at:
11
+ * http://scripts.sil.org/OFL
12
+ */
13
+
14
+ @font-face {
15
+ font-family: "Source Code Pro";
16
+ font-style: normal;
17
+ font-weight: 400;
18
+ src: local("Source Code Pro"),
19
+ local("SourceCodePro-Regular"),
20
+ url("../fonts/SourceCodePro-Regular.ttf") format("truetype");
21
+ }
22
+
23
+ @font-face {
24
+ font-family: "Source Code Pro";
25
+ font-style: normal;
26
+ font-weight: 700;
27
+ src: local("Source Code Pro Bold"),
28
+ local("SourceCodePro-Bold"),
29
+ url("../fonts/SourceCodePro-Bold.ttf") format("truetype");
30
+ }
31
+
32
+ /*
33
+ * Copyright (c) 2010, Łukasz Dziedzic (dziedzic@typoland.com),
34
+ * with Reserved Font Name Lato.
35
+ *
36
+ * This Font Software is licensed under the SIL Open Font License, Version
37
+ * 1.1.
38
+ *
39
+ * This license is copied below, and is also available with a FAQ at:
40
+ * http://scripts.sil.org/OFL
41
+ */
42
+
43
+ @font-face {
44
+ font-family: "Lato";
45
+ font-style: normal;
46
+ font-weight: 300;
47
+ src: local("Lato Light"),
48
+ local("Lato-Light"),
49
+ url("../fonts/Lato-Light.ttf") format("truetype");
50
+ }
51
+
52
+ @font-face {
53
+ font-family: "Lato";
54
+ font-style: italic;
55
+ font-weight: 300;
56
+ src: local("Lato Light Italic"),
57
+ local("Lato-LightItalic"),
58
+ url("../fonts/Lato-LightItalic.ttf") format("truetype");
59
+ }
60
+
61
+ @font-face {
62
+ font-family: "Lato";
63
+ font-style: normal;
64
+ font-weight: 700;
65
+ src: local("Lato Regular"),
66
+ local("Lato-Regular"),
67
+ url("../fonts/Lato-Regular.ttf") format("truetype");
68
+ }
69
+
70
+ @font-face {
71
+ font-family: "Lato";
72
+ font-style: italic;
73
+ font-weight: 700;
74
+ src: local("Lato Italic"),
75
+ local("Lato-Italic"),
76
+ url("../fonts/Lato-RegularItalic.ttf") format("truetype");
77
+ }
78
+
79
+ /*
80
+ * -----------------------------------------------------------
81
+ * SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
82
+ * -----------------------------------------------------------
83
+ *
84
+ * PREAMBLE
85
+ * The goals of the Open Font License (OFL) are to stimulate worldwide
86
+ * development of collaborative font projects, to support the font creation
87
+ * efforts of academic and linguistic communities, and to provide a free and
88
+ * open framework in which fonts may be shared and improved in partnership
89
+ * with others.
90
+ *
91
+ * The OFL allows the licensed fonts to be used, studied, modified and
92
+ * redistributed freely as long as they are not sold by themselves. The
93
+ * fonts, including any derivative works, can be bundled, embedded,
94
+ * redistributed and/or sold with any software provided that any reserved
95
+ * names are not used by derivative works. The fonts and derivatives,
96
+ * however, cannot be released under any other type of license. The
97
+ * requirement for fonts to remain under this license does not apply
98
+ * to any document created using the fonts or their derivatives.
99
+ *
100
+ * DEFINITIONS
101
+ * "Font Software" refers to the set of files released by the Copyright
102
+ * Holder(s) under this license and clearly marked as such. This may
103
+ * include source files, build scripts and documentation.
104
+ *
105
+ * "Reserved Font Name" refers to any names specified as such after the
106
+ * copyright statement(s).
107
+ *
108
+ * "Original Version" refers to the collection of Font Software components as
109
+ * distributed by the Copyright Holder(s).
110
+ *
111
+ * "Modified Version" refers to any derivative made by adding to, deleting,
112
+ * or substituting -- in part or in whole -- any of the components of the
113
+ * Original Version, by changing formats or by porting the Font Software to a
114
+ * new environment.
115
+ *
116
+ * "Author" refers to any designer, engineer, programmer, technical
117
+ * writer or other person who contributed to the Font Software.
118
+ *
119
+ * PERMISSION & CONDITIONS
120
+ * Permission is hereby granted, free of charge, to any person obtaining
121
+ * a copy of the Font Software, to use, study, copy, merge, embed, modify,
122
+ * redistribute, and sell modified and unmodified copies of the Font
123
+ * Software, subject to the following conditions:
124
+ *
125
+ * 1) Neither the Font Software nor any of its individual components,
126
+ * in Original or Modified Versions, may be sold by itself.
127
+ *
128
+ * 2) Original or Modified Versions of the Font Software may be bundled,
129
+ * redistributed and/or sold with any software, provided that each copy
130
+ * contains the above copyright notice and this license. These can be
131
+ * included either as stand-alone text files, human-readable headers or
132
+ * in the appropriate machine-readable metadata fields within text or
133
+ * binary files as long as those fields can be easily viewed by the user.
134
+ *
135
+ * 3) No Modified Version of the Font Software may use the Reserved Font
136
+ * Name(s) unless explicit written permission is granted by the corresponding
137
+ * Copyright Holder. This restriction only applies to the primary font name as
138
+ * presented to the users.
139
+ *
140
+ * 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
141
+ * Software shall not be used to promote, endorse or advertise any
142
+ * Modified Version, except to acknowledge the contribution(s) of the
143
+ * Copyright Holder(s) and the Author(s) or with their explicit written
144
+ * permission.
145
+ *
146
+ * 5) The Font Software, modified or unmodified, in part or in whole,
147
+ * must be distributed entirely under this license, and must not be
148
+ * distributed under any other license. The requirement for fonts to
149
+ * remain under this license does not apply to any document created
150
+ * using the Font Software.
151
+ *
152
+ * TERMINATION
153
+ * This license becomes null and void if any of the above conditions are
154
+ * not met.
155
+ *
156
+ * DISCLAIMER
157
+ * THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
158
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
159
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
160
+ * OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
161
+ * COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
162
+ * INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
163
+ * DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
164
+ * FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
165
+ * OTHER DEALINGS IN THE FONT SOFTWARE.
166
+ */
167
+