server

Restful json CherryPy server.

$ python server.py directory,... [-r|–read-only] [-c|–config filename]
CherryPy and Lucene VM integration issues:
  • Autoreload is not compatible with the VM initialization.
  • WorkerThreads must be attached to the VM.
  • Also recommended that the VM ignores keyboard interrupts for clean server shutdown.

WebSearcher

class server.WebSearcher(*directories, **kwargs)

Dispatch root with a delegated Searcher.

docs(id=None, fields='', multifields='')

Return ids or documents.

GET /docs

Return list of doc ids.

return:[int,... ]
GET /docs/int?

Return document mappings, optionally selected unique or multi-valued fields.

&fields=chars,...

&multifields=chars,...

return:{string: string|array,... }
index()

Return index information.

GET /

Return a mapping of the directory to the document count.

return:{string: int}
refresh()

Reopen searcher.

POST /refresh

search(q=None, count=None, start=0, fields='', multifields='', sort=None, facets='', hl='', mlt=None, **options)

Run query and return documents.

GET /search?

Return list of document objects and total doc count.

&q=chars&q.chars=...,
query and optional parser settings: q.field, q.op,...
&count=int&start=0
maximum number of docs to return and offset to start at
&fields=chars,...
only include selected fields
&multifields=chars,...
multi-valued fields returned in an array
&sort=[-]chars[:chars],...
field name, optional type, minus sign indicates descending
&facets=chars,...
include facet counts for given field names
&hl=chars,... &hl.count=1&hl.tag=strong&hl.enable=[fields|terms]
stored fields to return highlighted
optional maximum fragment count and html tag name
optionally enable matching any field or any term
&mlt=int&mlt.fields=chars,... &mlt.chars=...,
doc index (or id without a query) to find MoreLikeThis
optional document fields to match
optional MoreLikeThis settings: mlt.minTermFreq, mlt.minDocFreq,...
return:
{
“query”: string,
“count”: int,
“docs”: [{“__id__”: int, “__score__”: number, “__highlights__”: {string: array,... }, string: string|array,... },... ],
“facets”: {chars: {chars: int,... },... },
}
terms(name='', value=':', docs='', counts='', **options)

Return data about indexed terms.

GET /terms?

Return field names, with optional selection.

&option=chars

return:[string,... ]
GET /terms/chars

Return term values for given field name.

return:[string,... ]
GET /terms/chars/chars[*|:chars|~float]

Return term values (wildcards, slices, or fuzzy terms) for given field name.

return:[string,... ]
GET /terms/chars/chars

Return document count with given term.

return:int
GET /terms/chars/chars/docs

Return document ids with given term.

return:[int,... ]
GET /terms/chars/chars/docs/counts

Return document ids and frequency counts for given term.

return:[[int, int],... ]
GET /terms/chars/chars/docs/positions

Return document ids and positions for given term.

return:[[int, [int,... ]],... ]

WebIndexer

class server.WebIndexer(*args, **kwargs)

Bases: server.WebSearcher

Dispatch root which extends searcher to include write methods.

commit()

Commit write operations.

POST /commit

docs(id=None, fields='', multifields='', docs='[], ')

Add or return documents. See WebSearcher.docs() for GET method.

POST /docs

Add documents to index.

docs=[{string: string|array,... },... ]

fields(name='', **params)

Return or store a field’s parameters.

GET /fields

Return known field names.

return:[string,... ]
GET, PUT /fields/chars

Set and return parameters for given field name.

store=chars

index=chars

termvector=chars

return:{“store”: string, “index”: string, “termvector”: string}
search(q=None, **options)

Run or delete a query. See WebSearcher.search() for GET method.

DELETE /search?q=chars
Delete documents which match query.
server.main(root, path='', config=None)
Attach root and run server.

Table Of Contents

Previous topic

engine

Next topic

client

This Page