Package translate :: Package search :: Package indexing :: Module PyLuceneIndexer1 :: Class PyLuceneDatabase

[hide private]
[frames] | no frames]

# Class PyLuceneDatabase

source code

manage and use a pylucene indexing database

Instance Methods | [hide private]

PyLucene.Query

_create_query_for_string(self, text, require_all=True, analyzer=None) generate a query for a plain term of a string query | source code

PyLucene.Query

_create_query_for_field(self, field, value, analyzer=None) generate a field query | source code

PyLucene.Query

_create_query_combined(self, queries, require_all=True) generate a combined query | source code

_add_plain_term(self, document, term, tokenize=True) add a term to a document | source code

_add_field_term(self, document, field, term, tokenize=True) add a field term to a document | source code

subclass of CommonEnquire

get_query_result(self, query) return an object containing the results of a query | source code

list of dicts

search(self, query, fieldnames) return a list of the contents of specified fields for all matches of a query | source code

_writer_open(self) open write access for the indexing database and acquire an exclusive lock | source code

Inherited from `PyLuceneIndexer.PyLuceneDatabase`: `__del__`, `__init__`, `begin_transaction`, `cancel_transaction`, `commit_transaction`, `delete_document_by_id`, `flush`

Inherited from `PyLuceneIndexer.PyLuceneDatabase` (private): `_add_document_to_index`, `_create_empty_document`, `_create_query_for_query`, `_index_refresh`, `_writer_close`, `_writer_is_open`

Inherited from `CommonIndexer.CommonDatabase`: `delete_doc`, `get_field_analyzers`, `index_document`, `make_query`, `set_field_analyzers`

Inherited from `CommonIndexer.CommonDatabase` (private): `_decode`, `_walk_matches`

Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__str__`

Class Variables | [hide private]

Inherited from `PyLuceneIndexer.PyLuceneDatabase`: `INDEX_DIRECTORY_NAME`, `QUERY_TYPE` Inherited from `CommonIndexer.CommonDatabase`: `ANALYZER_DEFAULT`, `ANALYZER_EXACT`, `ANALYZER_PARTIAL`, `ANALYZER_TOKENIZE`, `field_analyzers`

Properties | [hide private]

Inherited from `object`: `__class__`

Method Details | [hide private]

### _create_query_for_string(self, text, require_all=True, analyzer=None)

source code

generate a query for a plain term of a string query

basically this function parses the string and returns the resulting query

Parameters:
  - `text` (str) - the query string
  - `require_all` (bool) - boolean operator (True -> AND (default) / False -> OR)
  - `analyzer` (bool) - the analyzer to be used possible analyzers are:
    - CommonDatabase.ANALYZER_TOKENIZE the field value is splitted to be matched word-wise
    - CommonDatabase.ANALYZER_PARTIAL the field value must start with the query string
    - CommonDatabase.ANALYZER_EXACT keep special characters and the like
Returns: PyLucene.Query
  resulting query object
Overrides: CommonIndexer.CommonDatabase._create_query_for_string

### _create_query_for_field(self, field, value, analyzer=None)

source code

generate a field query

this functions creates a field->value query

Parameters:
  - `field` (str) - the fieldname to be used
  - `value` (str) - the wanted value of the field
  - `analyzer` (bool) - the analyzer to be used possible analyzers are:
    - CommonDatabase.ANALYZER_TOKENIZE the field value is splitted to be matched word-wise
    - CommonDatabase.ANALYZER_PARTIAL the field value must start with the query string
    - CommonDatabase.ANALYZER_EXACT keep special characters and the like
Returns: PyLucene.Query
  resulting query object
Overrides: CommonIndexer.CommonDatabase._create_query_for_field

### _create_query_combined(self, queries, require_all=True)

source code

generate a combined query

Parameters:
  - `queries` (list of xapian.Query) - list of the original queries
  - `require_all` (bool) - boolean operator (True -> AND (default) / False -> OR)
Returns: PyLucene.Query
  the resulting combined query object
Overrides: CommonIndexer.CommonDatabase._create_query_combined

### _add_plain_term(self, document, term, tokenize=True)

source code

add a term to a document

Parameters:
  - `document` (xapian.Document | PyLucene.Document) - the document to be changed
  - `term` (str) - a single term to be added
  - `tokenize` (bool) - should the term be tokenized automatically
Overrides: CommonIndexer.CommonDatabase._add_plain_term

### _add_field_term(self, document, field, term, tokenize=True)

source code

add a field term to a document

Parameters:
  - `document` (xapian.Document | PyLucene.Document) - the document to be changed
  - `field` (str) - name of the field
  - `term` (str) - term to be associated to the field
  - `tokenize` (bool) - should the term be tokenized automatically
Overrides: CommonIndexer.CommonDatabase._add_field_term

### get_query_result(self, query)

source code

return an object containing the results of a query

Parameters:
  - `query` (a query object of the real implementation) - a pre-compiled query
Returns: subclass of CommonEnquire
  an object that allows access to the results
Overrides: CommonIndexer.CommonDatabase.get_query_result

### search(self, query, fieldnames)

source code

return a list of the contents of specified fields for all matches of a query

Parameters:
  - `query` (a query object of the real implementation) - the query to be issued
  - `fieldnames` (string | list of strings) - the name(s) of a field of the document content
Returns: list of dicts
  a list of dicts containing the specified field(s)
Overrides: CommonIndexer.CommonDatabase.search

### _writer_open(self)

source code

open write access for the indexing database and acquire an exclusive lock

Overrides: PyLuceneIndexer.PyLuceneDatabase._writer_open