Metadata-Version: 2.1
Name: oarepo-search
Version: 1.0.0
Summary: OArepo module that adds support for communities
Home-page: https://github.com/oarepo/oarepo-search
Author: Daniel Kopecký
Author-email: Daniel.Kopecky@techlib.cz
License: MIT
Keywords: invenio oarepo search
Platform: any
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Development Status :: 4 - Beta
Description-Content-Type: text/markdown
Requires-Dist: luqum
Provides-Extra: all
Requires-Dist: oarepo[tests] (~=3.3.60) ; extra == 'all'
Requires-Dist: pydocstyle ; extra == 'all'
Requires-Dist: isort ; extra == 'all'
Provides-Extra: tests
Requires-Dist: oarepo[tests] (~=3.3.60) ; extra == 'tests'
Requires-Dist: pydocstyle ; extra == 'tests'
Requires-Dist: isort ; extra == 'tests'


[![image][0]][1]
[![image][2]][3]
[![image][4]][5]
[![image][6]][7]

  [0]: https://github.com/oarepo/oarepo-search/workflows/CI/badge.svg
  [1]: https://github.com/oarepo/oarepo-search/actions?query=workflow%3ACI
  [2]: https://img.shields.io/github/tag/oarepo/oarepo-search.svg
  [3]: https://github.com/oarepo/oarepo-search/releases
  [4]: https://img.shields.io/pypi/dm/oarepo-search.svg
  [5]: https://pypi.python.org/pypi/oarepo-search
  [6]: https://img.shields.io/github/license/oarepo/oarepo-search.svg
  [7]: https://github.com/oarepo/oarepo-search/blob/master/LICENSE

# OARepo-Search

OArepo module that added auxiliary search features.

## Installation

OARepo-Search is on PyPI so all you need is:

``` console
$ pip install oarepo-search
```

## Configuration
### Supported languages
If you use multilingual fields ([oarepo-multilingual](https://github.com/oarepo/oarepo-multilingual)) and want use 
simple query for searching in the fields, you have to specify supported languages.

```python
OAREPO_SEARCH_SUPPORTED_LANGUAGES = ["cs", "en"]
```

### Search fields
Field settings for simple search (https://host.com/path/?q=<query>). Configuration is a dictionary, where key is the 
name of the 
endpoint and value is a list of supported fields. If you want to use a multilingual field, you can use an asterisk instead of the language, which is automatically replaced by OAREPO_SEARCH_SUPPORTED_FIELDS.

:warning: **Simple query does not support nested fields**: If you want search in nested fields you must use Lucene 
query with field specification (e.g.: "creator.role.title.cs:Karel Čapek")

```python
OAREPO_SEARCH_FIELDS = {
  "entrypoint_name": ["title.*", "creator"]
}
```

## Usage
### Query parser
The library provides an extension to the default parser provided by Invenio. The use of the query parser is 
described in the module [invenio-records-rest](https://invenio-records-rest.readthedocs.io/en/latest/usage.
html#query-parser).

The library can use a simple query as in invenio when you enter a search query in the form: q = <word>, but this simple expression cannot search in nested fields. Therefore, the library supports queries in Lucene syntax with support for nested field search (eg "title: robot AND creator.name:Capek")

Provide query parser from this library into your search_factory.

```python
from invenio_records_rest.query import default_search_factory
from oarepo_search.query_parsers import query_parser



def my_search_factory(*args, **kwargs):
    return default_search_factory(*args,
                                  query_parser=query_parser, **kwargs)

RECORDS_REST_ENDPOINTS = {
    'recid': {
        # ...
        'search_factory_imp': my_search_factory,
     }
}
```

Copyright (C) 2021 CESNET.

OARepo-Search is free software; you can redistribute it and/or
modify it under the terms of the MIT License; see LICENSE file for more
details.


# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Better explanation of the difference between the file ("CHANGELOG")
and its function "the change log".

### Changed
- Refer to a "change log" instead of a "CHANGELOG" throughout the site
to differentiate between the file and the purpose of the file — the
logging of changes.

### Removed
- Remove empty sections from CHANGELOG, they occupy too much space and
create too much noise in the file. People will have to assume that the
missing sections were intentionally left out because they contained no
notable changes.








