All Projects → swistakm → solrq

swistakm / solrq

Licence: BSD-3-Clause license
Python Solr query utility // http://solrq.readthedocs.org/en/latest/

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to solrq

solr-container
Ansible Container project that manages the lifecycle of Apache Solr on Docker.
Stars: ✭ 17 (-5.56%)
Mutual labels:  solr
solr-zkutil
Solr Cloud and ZooKeeper CLI
Stars: ✭ 14 (-22.22%)
Mutual labels:  solr
jstarcraft-nlp
专注于解决自然语言处理领域的几个核心问题:词法分析,句法分析,语义分析,语种检测,信息抽取,文本聚类和文本分类. 为相关领域的研发人员提供完整的通用设计与参考实现. 涵盖了多种自然语言处理算法,适配了多个自然语言处理框架. 兼容Lucene/Solr/ElasticSearch插件.
Stars: ✭ 92 (+411.11%)
Mutual labels:  solr
GeoParser
Extract and Visualize location from any file
Stars: ✭ 48 (+166.67%)
Mutual labels:  solr
searchhub
Fusion demo app searching open-source project data from the Apache Software Foundation
Stars: ✭ 42 (+133.33%)
Mutual labels:  solr
skipchunk
Extracts a latent knowledge graph from text and index/query it in elasticsearch or solr
Stars: ✭ 18 (+0%)
Mutual labels:  solr
solr wrapper
Wrap your tests with Solr 5+
Stars: ✭ 22 (+22.22%)
Mutual labels:  solr
hello-nlp
A natural language search microservice
Stars: ✭ 85 (+372.22%)
Mutual labels:  solr
ltr-tools
Set of command line tools for Learning To Rank
Stars: ✭ 13 (-27.78%)
Mutual labels:  solr
kitodo-presentation
Kitodo.Presentation is a feature-rich framework for building a METS- or IIIF-based digital library. It is part of the Kitodo Digital Library Suite.
Stars: ✭ 33 (+83.33%)
Mutual labels:  solr
django-solr
Solr Search Engine ORM for Django
Stars: ✭ 24 (+33.33%)
Mutual labels:  solr
multi-select-facet
An example of multi-select facet with Solr, Vue and Go
Stars: ✭ 30 (+66.67%)
Mutual labels:  solr
chorus
Towards an open source stack for e-commerce search
Stars: ✭ 86 (+377.78%)
Mutual labels:  solr
x
Commerce Search & Discovery frontend web components
Stars: ✭ 54 (+200%)
Mutual labels:  solr
IATI.cloud
The open-source IATI datastore for IATI data with RESTful web API providing XML, JSON, CSV output. It extracts and parses IATI XML files referenced in the IATI Registry and powered by Apache Solr.
Stars: ✭ 35 (+94.44%)
Mutual labels:  solr
solr-vector-scoring
Vector Plugin for Solr: calculate dot product / cosine similarity on documents
Stars: ✭ 28 (+55.56%)
Mutual labels:  solr
vacomall
☀️☀️ 基于 dubbo 实现的分布式电商平台。
Stars: ✭ 42 (+133.33%)
Mutual labels:  solr
nlpir-analysis-cn-ictclas
Lucene/Solr Analyzer Plugin. Support MacOS,Linux x86/64,Windows x86/64. It's a maven project, which allows you change the lucene/solr version. //Maven工程,修改Lucene/Solr版本,以兼容相应版本。
Stars: ✭ 71 (+294.44%)
Mutual labels:  solr
solr-stack
Ambari stack service for easily installing and managing Solr on HDP cluster
Stars: ✭ 18 (+0%)
Mutual labels:  solr
wasp
WASP is a framework to build complex real time big data applications. It relies on a kind of Kappa/Lambda architecture mainly leveraging Kafka and Spark. If you need to ingest huge amount of heterogeneous data and analyze them through complex pipelines, this is the framework for you.
Stars: ✭ 19 (+5.56%)
Mutual labels:  solr

Build Status Coverage Status Documentation Status

solrq

solrq is a Python Solr query utility. It helps making query strings for Solr and also helps with escaping reserved characters. solrq is has no external dependencies and is compatibile with python2.6, python2.7, python3.3, python3.4, python3.5, pypy and pypy3. It might be compatibile with other python releases/implentations but this has not been tested yet or is no longer tested (e.g python3.2).

pip install solrq

And you're ready to go!

usage

Everything in solrq is about Q() object. Drop into python repl and just feed it with bunch of field and search terms to see how it works:

>>> from solrq import Q
>>> # note: all terms in single Q object are implicitely joined with 'AND'
>>> query = Q(type="animal", species="dog")
>>> query
<Q: type:animal AND species:dog>

>>> # ohh, forgot about cats?
>>> query | Q(type="animal", species="cat")
<Q: (type:animal AND species:dog) OR (type:animal AND species:cat)>

>>># more a cat lover? Let's give them a boost boost
>>> Q(type="animal") & (Q(species="cat")^2 | Q(species="dog"))
<Q: type:animal AND ((species:cat^2) OR species:dog)>

But what to do with this Q? Simply pass it to your Solr library of choice, like pysolr or mysolr. Most of python Solr libraries expect simple string as a query parameter and do not bother with escaping of reserved characters so you must take care of that by yourself. This is why solrq integrates so easily. Here is an example how you can use it with pysolr:

from solrq import Q
import pysolr

solr = Solr("<your solr url>")

# simply using Q object
solr.search(Q(text="easy as f***"))

# or explicitely making it string
solr.search(str(Q(text="easy as f***")))

quick reference

Full reference can be found in API reference documentation page but here is a short reference.

boosting queries

Use python ^ operator:

>>> Q(text='cat') ^ 2
<Q: text:cat^2>

AND queries

Use python & operator:

>>> Q(text='cat') & Q(text='dog')
<Q: text:cat AND text:dog>

OR queries

Use python | operator:

>>> Q(text='cat') | Q(text='dog')
<Q: text:cat OR text:dog>

NOT queries

Use python ~ operator:

>>> ~ Q(text='cat')
<Q: !text:cat>

ranges

Use solrq.Range wrapper:

>>> from solrq import Range
>>> Q(age=Range(18, 25))
<Q: age:[18 TO 25]>

proximity searches

Use solrq.Proximity wrapper:

>>> from solrq import Proximity
>>> Q(age=Proximity("cat dogs", 5))
<Q: age:"cat\ dogs"~5>

safe strings

All raw string values are treated as unsafe by default and will be escaped to ensure that final query string will not be broken by some rougue search value. This of course can be disabled if you know what you're doing using Value wrapper:

>>> from solrq import Q, Value
>>> Q(type='foo bar[]')
<Q: type:foo\ bar\[\]>
>>> Q(type=Value('foo bar[]', safe=True))
<Q: type:foo bar[]>

timedeltas, datetimes

Simply as:

>>> from datetime import datetime, timedelta
>>> Q(date=datetime(1970, 1, 1))
<Q: date:"1970-01-01T00:00:00Z">
>>> # note that timedeltas has any sense mostly with ranges
>>> Q(delta=timedelta(days=1))
<Q: delta:NOW+1DAYS+0SECONDS+0MILLISECONDS>

field wildcard

If you need to use wildcards in field names just use dict and unpack it inside of Q() instead of using keyword arguments:

    >>> Q(**{"*_t": "text_to_search"})
    <Q: *_t:text_to_search>

contributing

Any contribution is welcome. Issues, suggestions, pull requests - whatever. There are no strict contribution guidelines beyond PEP-8 and sanity. Code style is checked with flakes8 and any PR that has failed build will not be merged.

One thing: if you submit a PR please do not rebase it later unless you are asked for that explicitely. Reviewing pull requests that suddenly had their history rewritten just drives me crazy.

testing

Tests are run using tox. Simply install it and run:

pip install tox
tox

And that's all.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].