Exemplo n.º 1
0
class _DefaultSearchSchema(SchemaClass):
    """
  General search schema
  """
    object_key = ID(stored=True, unique=True)
    id = NUMERIC(numtype=int, bits=64, signed=False, stored=True, unique=False)
    object_type = ID(stored=True, unique=False)
    creator = ID(stored=True)
    owner = ID(stored=True)

    #: security index. This list roles and user/group ids allowed to *see* this
    #: content
    allowed_roles_and_users = KEYWORD(stored=True)

    #: tags indexing
    tag_ids = KEYWORD(stored=True)
    tag_text = TEXT(stored=False, analyzer=accent_folder)

    # hierarchical index of ids path ('/' is the separator)
    parent_ids = FieldType(format=Existence(),
                           analyzer=PathTokenizer(),
                           stored=True,
                           unique=False)

    name = TEXT(stored=True, analyzer=accent_folder)
    slug = ID(stored=True)
    description = TEXT(stored=True, analyzer=accent_folder)
    text = TEXT(stored=False, analyzer=accent_folder)
Exemplo n.º 2
0
 def __init__(self, stored=False, unique=False, field_boost=1.0):
     """
     :param stored: Whether the value of this field is stored with the document.
     """
     self.format = Existence(analyzer=IDAnalyzer(), field_boost=field_boost)
     self.stored = stored
     self.unique = unique
Exemplo n.º 3
0
Arquivo: fields.py Projeto: oier/Yaki
    def __init__(self, stored=False):
        """
        :param stored: Whether the value of this field is stored with the
            document.
        """

        self.stored = stored
        self.format = Existence(None)
Exemplo n.º 4
0
def test_existence_postings():
    postings = []
    docnum = 0
    for _ in xrange(0, 20):
        docnum += randint(1, 10)
        postings.append((docnum, 1))

    assert_equal(postings, roundtrip(postings, Existence(), "frequency"))
Exemplo n.º 5
0
    def __init__(self, stored=False, unique=False):
        """
        :param stored: Whether the value of this field is stored with the document.
        :param unique: Whether the value of this field is unique per-document.
        """

        self.stored = stored
        self.unique = unique
        self.format = Existence()
Exemplo n.º 6
0
Arquivo: fields.py Projeto: oier/Yaki
    def __init__(self,
                 type=int,
                 stored=False,
                 unique=False,
                 field_boost=1.0,
                 decimal_places=0,
                 shift_step=4,
                 signed=True):
        """
        :param type: the type of numbers that can be stored in this field: one
            of ``int``, ``long``, ``float``, or ``Decimal``.
        :param stored: Whether the value of this field is stored with the
            document.
        :param unique: Whether the value of this field is unique per-document.
        :param decimal_places: specifies the number of decimal places to save
            when storing Decimal instances as ``int`` or ``float``.
        :param shift_steps: The number of bits of precision to shift away at
            each tiered indexing level. Values should generally be 1-8. Lower
            values yield faster searches but take up more space. A value
            of `0` means no tiered indexing.
        :param signed: Whether the numbers stored in this field may be
            negative.
        """

        self.type = type
        if self.type is int:
            self._to_text = int_to_text
            self._from_text = text_to_int
            self.sortable_type = int
            self.sortable_typecode = "i" if signed else "I"
        elif self.type is long:
            self._to_text = long_to_text
            self._from_text = text_to_long
            self.sortable_type = long
            self.sortable_typecode = "q" if signed else "Q"
        elif self.type is float:
            self._to_text = float_to_text
            self._from_text = text_to_float
            self.sortable_typecode = "f"
        elif self.type is Decimal:
            raise TypeError("To store Decimal instances, set type to int or "
                            "float and use the decimal_places argument")
        else:
            raise TypeError("%s field type can't store %r" %
                            (self.__class__, self.type))

        self.stored = stored
        self.unique = unique
        self.decimal_places = decimal_places
        self.shift_step = shift_step
        self.signed = signed
        self.format = Existence(analyzer=IDAnalyzer(), field_boost=field_boost)
Exemplo n.º 7
0
 def __init__(self, stored=False, unique=False, expression=None, field_boost=1.0):
     """
     :param stored: Whether the value of this field is stored with the
         document.
     :param unique: Whether the value of this field is unique per-document.
     :param expression: The regular expression object to use to extract
         tokens. The default expression breaks tokens on CRs, LFs, tabs,
         spaces, commas, and semicolons.
     """
     
     expression = expression or re.compile(r"[^\r\n\t ,;]+")
     analyzer = RegexAnalyzer(expression=expression)
     self.format = Existence(analyzer=analyzer, field_boost=field_boost)
     self.stored = stored
     self.unique = unique
Exemplo n.º 8
0
 def __init__(self, stored=False):
     self.stored = stored
     self.format = Existence()
Exemplo n.º 9
0
 def __init__(self, type=int, stored=False, unique=False, field_boost=1.0):
     self.type = type
     self.stored = stored
     self.unique = unique
     self.format = Existence(analyzer=IDAnalyzer(), field_boost=field_boost)
Exemplo n.º 10
0
def test_existence_postings():
    content = u("alfa bravo charlie")
    assert _roundtrip(content, Existence(), "frequency") == [("alfa", 1), ("bravo", 1), ("charlie", 1)]