(self, **kw)
Returns the document number of the document matching the given
        keyword arguments, where the keyword keys are field names and the
        values are terms that must appear in the field.

        >>> docnum = searcher.document_number(path=u"/a/b")

        Where Searcher.document_numbers() returns a generator, this function
        returns either an int or None. Use it when you assume the given keyword
        arguments either match zero or one documents (i.e. at least one of the
        fields is a unique key).

        :rtype: int
Returns the document number of the document matching the given
        keyword arguments, where the keyword keys are field names and the
        values are terms that must appear in the field.
Returns the document number of the document matching the given keyword arguments where the keyword keys are field names and the values are terms that must appear in the field .
def document_number(self, **kw):
        """Returns the document number of the document matching the given
        keyword arguments, where the keyword keys are field names and the
        values are terms that must appear in the field.

        >>> docnum = searcher.document_number(path=u"/a/b")

        Where Searcher.document_numbers() returns a generator, this function
        returns either an int or None. Use it when you assume the given keyword
        arguments either match zero or one documents (i.e. at least one of the
        fields is a unique key).

        :rtype: int
        """

        # In the common case where only one keyword was given, just use
        # first_id() instead of building a query.

        self._kw_to_text(kw)
        if len(kw) == 1:
            k, v = list(kw.items())[0]
            try:
                return self.reader().first_id(k, v)
            except TermNotFound:
                return None
        else:
            m = self._query_for_kw(kw).matcher(self, self.boolean_context())
            if m.is_active():
                return m.id()
def document_number ( self , * * kw ) : # In the common case where only one keyword was given, just use # first_id() instead of building a query. self . _kw_to_text ( kw ) if len ( kw ) == 1 : k , v = list ( kw . items ( ) ) [ 0 ] try : return self . reader ( ) . first_id ( k , v ) except TermNotFound : return None else : m = self . _query_for_kw ( kw ) . matcher ( self , self . boolean_context ( ) ) if m . is_active ( ) : return m . id ( )