Match json with lucece-like query
Project description
# json_matcher
Match json object with query like elasticsearch/lucene query.
examples (jrep)
# cat a.txt { “foo”: “bar”, “bar”: “foo” } # jrep “foo:bar” /tmp/a.txt { “foo”: “bar”, “bar”: “foo” }
examples (json_matcher)
>>> import json_matcher >>> matcher = json_matcher.compile('foo:bar bar:foo') >>> j = dict(foo='bar', bar='foo') >>> m = matcher.match(j) >>> m.groups() [('foo', 'bar'), ('bar', 'foo')]>>> matcher = json_matcher.compile('foo:>10 bar:foo') >>> j = dict(foo=11, bar='foo') >>> matcher.match(j).groups() [('foo', 11), ('bar', 'foo')] >>> j = dict(foo=9, bar='foo') >>> matcher.match(j) >>> m = matcher.match(j) >>> print(m) None>>> json_matcher.match('foo:[10 TO 20] AND bar:foo', dict(foo=11, bar='foo')).groups() [('foo', 11), ('bar', 'foo')]>>> nested = dict(A=dict(B=dict(C='Hello World'))) >>> json_matcher.match('A.B.C:"Hello World"', nested).groups() [('A.B.C', 'Hello World')]
match text or number with `field_name:value`
match regular expression with `field_name:/regular expression/`
match range with `field_name:[10 TO 20]`, `field_name:[10 TO 20}` (exclusive 20)
match range(open range) with `field_name:>20` (like elasticsearch not lucene)
match field existence with `_exists_:field_name`
match expression with `_expression:"python expression"`
- TODO:
multiple match with high performace (with Ahocorasik and RE2???)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file json_matcher-0.0.14.tar.gz
.
File metadata
- Download URL: json_matcher-0.0.14.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 615af319670bbf0a51c128f2fd34d0ba3e47f3441f472d41e26ed67a66962659 |
|
MD5 | ca8e0854e51d68e6e41955218eb58004 |
|
BLAKE2b-256 | 41f2b8c853502a6ebd93863c02c0da61c2fff7de4f416f2fa8a07b55cafcb549 |