search_flip 2.1.0.beta2 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +112 -7
  3. data/lib/search_flip/version.rb +1 -1
  4. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b3740c9ca1f4b34538a0302d4efc92afb12ee845d1b534241070ade3255b4dd
4
- data.tar.gz: afb51d3e77ef804e3487da46a8f5db33a9d5baa9dd17337afb09fa4874b710e3
3
+ metadata.gz: cda3eb59fdf7fabf986510c923cbded7f6a1219d734be60a406265d7ec685893
4
+ data.tar.gz: a30be3c6195e1864b4a37899e079e096129692ec0bb5ac0f78a0cceaf15468a2
5
5
  SHA512:
6
- metadata.gz: 96e43715270ac96cd15933a6e2243c9f61dec661abe6b70e1aba93d411a7ebaa19c528a6c9f5d11950babd48f144afef06a4b5be29d91bc2d820bc014b81e951
7
- data.tar.gz: be195c055a264206dd2a85657fd8c874d8e09661e6bb9d39f0fbc80f1c30cda3ce006082540c739d00eadecbf0f4e2fd68805e4c0099393bbe153986864a67a3
6
+ metadata.gz: df70d9f06aecbd84e7a5cb1ec16ffdd408a53da7a08f15fac4761a2e70b38b667ee4688abe7d81195eb6389e6decf2b591689a7002b75ca28cae16f8fa5bb88b
7
+ data.tar.gz: f903399ac8baa4b4a41ebcf3d378b64fbae236a553dc975b90b3c13a9b50e39bdbc6508a6098884510205ae42a55bf057a94f2fa73a4906a5d053d4f86ac7ba8
data/README.md CHANGED
@@ -297,9 +297,116 @@ temporary, class inherting from UserIndex and overwriting `index_name`.
297
297
  SearchFlip supports even more advanced usages, like e.g. post filters, filtered
298
298
  aggregations or nested aggregations via simple to use API methods.
299
299
 
300
- ### Post filters
300
+ ### Query/Filter Criteria Methods
301
301
 
302
- All criteria methods (`#where`, `#where_not`, `#range`, etc.) are available
302
+ SearchFlip provides powerful methods to query/filter Elasticsearch:
303
+
304
+ * `where`
305
+
306
+ Feels like ActiveRecord's `where` and performs a bool filter clause
307
+ to the request:
308
+
309
+ ```ruby
310
+ CommentIndex.where(reviewed: true)
311
+ CommentIndex.where(likes: 0 .. 10_000)
312
+ CommentIndex.where(state: ["approved", "rejected"])
313
+ ```
314
+
315
+ * `where_not`
316
+
317
+ Like `where`, but exluding the matching documents:
318
+
319
+ ```ruby
320
+ CommentIndex.where_not(id: [1, 2, 3])
321
+ ```
322
+
323
+ * `range`
324
+
325
+ To add a range filter query:
326
+
327
+ ```ruby
328
+ CommentIndex.range(:created_at, gt: Date.today - 1.week, lt: Date.today)
329
+ ```
330
+
331
+ * `filter`
332
+
333
+ Use `filter` to add raw filter queries:
334
+
335
+ ```ruby
336
+ CommentIndex.filter(term: { state: "approved" })
337
+ ```
338
+
339
+ * `should`
340
+
341
+ Use `should` to add raw should queries:
342
+
343
+ ```ruby
344
+ CommentIndex.should(term: { state: "approved" })
345
+ ```
346
+
347
+ * `must`
348
+
349
+ Use `must` to add raw must queries:
350
+
351
+ ```ruby
352
+ CommentIndex.must(term: { state: "approved" })
353
+
354
+ CommentIndex.must(
355
+ bool: {
356
+ should: [
357
+ { terms: { state: ["approved", "rejected"] }},
358
+ { term: { username: "mrkamel" }}
359
+ ]
360
+ }
361
+ )
362
+ ```
363
+
364
+ * `must_not`
365
+
366
+ Like `must`, but excluding the matching documents:
367
+
368
+ ```ruby
369
+ CommentIndex.must_not(term: { state: "approved" })
370
+ ```
371
+
372
+ * `search`
373
+
374
+ Adds a query string query, with AND as default filter:
375
+
376
+ ```ruby
377
+ CommentIndex.search("harry potter")
378
+ CommentIndex.search("state:approved")
379
+ CommentIndex.search("username:a*")
380
+ CommentIndex.search("state:approved OR state:rejected")
381
+ ```
382
+
383
+ * `exists`
384
+
385
+ Use `exists` to add an `exists` query:
386
+
387
+ ```ruby
388
+ CommentIndex.exists(:state)
389
+ ```
390
+
391
+ * `exists_not`
392
+
393
+ Like `exists`, but excluding the matching documents:
394
+
395
+ ```ruby
396
+ CommentIndex.exists_not(:state)
397
+ ```
398
+
399
+ * `match_all`
400
+
401
+ Simply matches all documents:
402
+
403
+ ```ruby
404
+ CommentIndex.match_all
405
+ ```
406
+
407
+ ### Post Query/Filter Criteria Methods
408
+
409
+ All query/filter criteria methods (`#where`, `#where_not`, `#range`, etc.) are available
303
410
  in post filter mode as well, ie. filters/queries applied after aggregations
304
411
  are calculated. Checkout the ElasticSearch docs for further info.
305
412
 
@@ -379,11 +486,10 @@ query = CommentIndex.highlight(:title).search("hello")
379
486
  query.results[0]._hit.highlight.title # => "<em>hello</em> world"
380
487
  ```
381
488
 
382
- ### Advanced Criteria Methods
489
+ ### Other Criteria Methods
383
490
 
384
- There are even more methods to make your life easier, namely `source`,
385
- `scroll`, `profile`, `includes`, `preload`, `find_in_batches`, `find_each`,
386
- `find_results_in_batches`, `failsafe` and `unscope` to name just a few:
491
+ There are so many chainable criteria methods to make your life easier.
492
+ For a full list, checkout the reference docs.
387
493
 
388
494
  * `source`
389
495
 
@@ -714,4 +820,3 @@ $ rspec
714
820
  ```
715
821
 
716
822
  That's it.
717
-
@@ -1,5 +1,5 @@
1
1
 
2
2
  module SearchFlip
3
- VERSION = "2.1.0.beta2"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: search_flip
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0.beta2
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Vetter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-08 00:00:00.000000000 Z
11
+ date: 2019-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -229,9 +229,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
229
229
  version: '0'
230
230
  required_rubygems_version: !ruby/object:Gem::Requirement
231
231
  requirements:
232
- - - ">"
232
+ - - ">="
233
233
  - !ruby/object:Gem::Version
234
- version: 1.3.1
234
+ version: '0'
235
235
  requirements: []
236
236
  rubyforge_project:
237
237
  rubygems_version: 2.7.3