Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Readme
A simple query builder for Amazon Cloudsearch Structured query parser.
|travis| |coveralls| |downloads| |version| |license| |requires|
.. contents:: :local: :depth: 1
Provide a simple query builder for Amazon Cloudsearch Structured query parser.
Please refer to the following link regarding Structured Search Syntax .
At the moment, this library is compatible only to Structured Search Syntax .
It does not have any plans corresponding to the other query parser(lucene, dismax, simple).
If you want the lucene query builder, it's a good idea is to use the following library.
This library does not handle to generate queries that are not related to Structured Search Syntax. Ex) size, facets ...
Make environment with pip::
$ pip install csquery
Syntax: (and boost=N EXPRESSION EXPRESSION ... EXPRESSIONn)
.. code-block:: python
from csquery.structured import and_, field
q = and_(title='star', actors='Harrison Ford', year=('', 2000)) q() #=> (and title:'star' actors:'Harrison Ford' year:{,2000])
q = and_({'title': 'star'}, {'title': 'star2'}, boost=2) q() #=> (and boost=2 title:'star' title:'star2')
and_({'title': 'star'}, {'actors': 'Harrison Ford'}, {'year': ('', 2000)}) and_(field('star', 'title'), field('Harrison Ford', 'actors'), field(('', 2000), 'year'))
Syntax: (or boost=N EXPRESSION1 EXPRESSION2 ... EXPRESSIONn)
.. code-block:: python
from csquery.structured import or_, field
q = or_(title='star', actors='Harrison Ford', year=('', 2000)) q() #=> (or title:'star' actors:'Harrison Ford' year:{,2000])
q = or_({'title': 'star'}, {'title': 'star2'}, boost=2) q() #=> (or boost=2 title:'star' title:'star2')
Syntax: (not boost=N EXPRESSION)
.. code-block:: python
from csquery.structured import not_, and_
q = not_(and_(actors='Harrison Ford', year=('', 2010))) q() #=> (not (and actors:'Harrison Ford' year:{,2010]))
q = not_(and_(actors='Harrison Ford', year=('', 2010)), boost=2) q() #=> (not boost=2 (and actors:'Harrison Ford' year:{,2010]))
Syntax: (near field=FIELD distance=N boost=N 'STRING')
.. code-block:: python
from csquery.structured import near
q = near('teenage vampire', boost=2, field='plot', distance=2) q() #=> (near field=plot distance=2 boost=2 'teenage vampire')
Syntax: (phrase field=FIELD boost=N 'STRING')
.. code-block:: python
from csquery.structured import phrase
q = phrase('star', boost=2, field='title') q() #=> (phrase field=title boost=2 'star')
Syntax: (prefix field=FIELD boost=N 'STRING')
.. code-block:: python
from csquery.structured import prefix
q = prefix('star', boost=2, field='title') q() #=> (prefix field=title boost=2 'star')
Syntax: (range field=FIELD boost=N RANGE)
.. code-block:: python
from csquery.structured import range_
q = range_((1990, 2000)) q() #=> (range [1990,2000]) q = range_((None, 2000)) q() #=> (range {,2000]) q = range_((1990,)) q() #=> (range [1990,})
q = range_((1990, 2000), field='date', boost=2) q() #=> (range field=date boost=2 [1990,2000])
q = range_('[1990,2000]') q() #=> (range [1990,2000])
q = range_(('', 2000)) q() #=> (range {,2000]) q = range_('{,2000]') q() #=> (range {,2000])
q = range_((1990, None)) q() #=> (range [1990,}) q = range_((1990, '')) q() #=> (range [1990,}) q = range_('[1990,}') q() #=> (range [1990,})
Syntax: (term field=FIELD boost=N 'STRING'|VALUE)
.. code-block:: python
from csquery.structured import term
q = term(2000, field='year', boost=2) q() #=> (term field=year boost=2 2000)
q = term('star', field='title', boost=2) q() #=> (term field=title boost=2 'star')
.. code-block:: python
from csquery.structured import and_, or_, not_, term
q = and_( not_('test', field='genres'), or_( term('star', field='title', boost=2), term('star', field='plot') ) ) q() #=> (and (not field=genres 'test') (or (term field=title boost=2 'star') (term field=plot 'star')))
http://boto.readthedocs.org/en/latest/ref/cloudsearch2.html
.. code-block:: python
from csquery.structured import and_ from boto.cloudsearch2.layer2 import Layer2
conn = Layer2( region='ap-northeast-1', aws_access_key_id=[AWS ACCESSS KEY ID], aws_secret_access_key=[AWS SECRET KEY], ) domain = conn.lookup('search_domain_name') search_service = domain.get_search_service()
q = and_(title='star', actors='Harrison Ford', year=('', 2000)) result = search_service.search(q=q(), parser='structured')
See the LICENSE.rst file for specific terms.
Thanks.
#4 <https://github.com/tell-k/csquery/pull/4>
_.#3 <https://github.com/tell-k/csquery/pull/3>
_.#2 <https://github.com/tell-k/csquery/pull/2>
_.#1 <https://github.com/tell-k/csquery/pull/1>
_... |travis| image:: https://travis-ci.org/tell-k/csquery.svg?branch=master :target: https://travis-ci.org/tell-k/csquery
.. |coveralls| image:: https://coveralls.io/repos/tell-k/csquery/badge.png :target: https://coveralls.io/r/tell-k/csquery :alt: coveralls.io
.. |requires| image:: https://requires.io/github/tell-k/csquery/requirements.svg?branch=master :target: https://requires.io/github/tell-k/csquery/requirements/?branch=master :alt: requirements status
.. |downloads| image:: https://img.shields.io/pypi/dm/csquery.svg :target: http://pypi.python.org/pypi/csquery/ :alt: downloads
.. |version| image:: https://img.shields.io/pypi/v/csquery.svg :target: http://pypi.python.org/pypi/csquery/ :alt: latest version
.. |license| image:: https://img.shields.io/pypi/l/csquery.svg :target: http://pypi.python.org/pypi/csquery/ :alt: license
FAQs
A simple query builder for Amazon Cloudsearch structured query parser.
We found that csquery demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.