xappy.fieldactions.FieldActions

Package xappy :: Module fieldactions :: Class FieldActions |
[frames] | no frames]

# Class FieldActions

source code

    object --+
             |
            FieldActions

An object describing the actions to be performed on a field.

The supported actions are:

- STORE_CONTENT: store the unprocessed content of the field in the search engine database. All fields which need to be displayed or used when displaying the search results need to be given this action.
- INDEX_EXACT: index the exact content of the field as a single search term. Fields whose contents need to be searchable as an "exact match" need to be given this action.
- INDEX_FREETEXT: index the content of this field as text. The content will be split into terms, allowing free text searching of the field. Four optional parameters may be supplied:
  - 'weight' is a multiplier to apply to the importance of the field. This must be an integer, and the default value is 1.
  - 'language' is the language to use when processing the field. This can be expressed as an ISO 2-letter language code. The supported languages are those supported by the xapian core in use.
  - 'stop' is an iterable of stopwords to filter out of the generated terms. Note that due to Xapian design, only non-positional terms are affected, so this is of limited use.
  - 'spell' is a boolean flag - if true, the contents of the field will be used for spelling correction.
  - 'nopos' is a boolean flag - if true, positional information is not stored.
  - 'allow_field_specific' is a boolean flag - if False, prevents terms with the field prefix being generated. This means that searches specific to this field will not work, and thus should only be used when only non-field specific searches are desired. Defaults to True.
  - 'search_by_default' is a boolean flag - if False, the field will not be searched by non-field specific searches. If True, or omitted, the field will be included in searches for non field-specific searches.
- SORTABLE: index the content of the field such that it can be used to sort result sets. It also allows result sets to be restricted to those documents with a field values in a given range. One optional parameter may be supplied:
  - 'type' is a value indicating how to sort the field. It has several possible values:
    - 'string' - sort in lexicographic (ie, alphabetical) order. This is the default, used if no type is set.
    - 'float' - treat the values as (decimal representations of) floating point numbers, and sort in numerical order. The values in the field must be valid floating point numbers (according to Python's float() function).
    - 'date' - sort in date order. The values must be valid dates (either Python datetime.date objects, or ISO 8601 format (ie, YYYYMMDD or YYYY-MM-DD).
- COLLAPSE: index the content of the field such that it can be used to "collapse" result sets, such that only the highest result with each value of the field will be returned.
- TAG: the field contains tags; these are strings, which will be matched in a case insensitive way, but otherwise must be exact matches. Tag fields can be searched for by making an explict query (ie, using query_field(), but not with query_parse()). A list of the most frequent tags in a result set can also be accessed easily.
- FACET: the field represents a classification facet; these are strings which will be matched exactly, but a list of all the facets present in the result set can also be accessed easily - in addition, a suitable subset of the facets, and a selection of the facet values, present in the result set can be calculated. One optional parameter may be supplied:
  - 'type' is a value indicating the type of facet contained in the field:
    - 'string' - the facet values are exact binary strings.
    - 'float' - the facet values are floating point numbers.

Instance Methods
__init__(self, fieldname) x.__init__(...) initializes x; see x.__class__.__doc__ for signature | source code
add(self, field_mappings, action, **kwargs) Add an action to perform on a field. | source code
perform(self, doc, value, context) Perform the actions on the field. | source code
Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__str__`

Class Variables
| STORE_CONTENT = `1`
| INDEX_EXACT = `2`
| INDEX_FREETEXT = `3`
| SORTABLE = `4`
| COLLAPSE = `5`
| TAG = `6`
| FACET = `7`
| SORT_AND_COLLAPSE = `-1`

Properties
Inherited from `object`: `__class__`

Method Details

### __init__(self, fieldname) (Constructor) | source code
x.__init__(...) initializes x; see x.__class__.__doc__ for signature Overrides: object.__init__ (inherited documentation)

### perform(self, doc, value, context) | source code
Perform the actions on the field. `doc` is a ProcessedDocument to store the result of the actions in. `value` is a string holding the value of the field. `context` is an ActionContext object used to keep state in.