-
debseach3 definition
The debseach3 library are a wrapper on top of Whoosh (python free text search engine) to make it easier to create and search using Prism data. Here are all the methods in it and how to create and use.
Properties
addcount How many documents where added. index The open index to use for creating, updating and searching for documents indexpath The folder where the search base is located. It will be 1 or more files depending on updates done. schema Return the schema defined in search files.
The one we uses for this simple base search is:
- title | that is stored
- content | text blob that only are index but not stored
- url | stored and used as unique id for the documentsupdatedcount How many documents where updated writer Used to update the index or create new documents, but you should only use the updateindex method unless you have extended this base and changed the schema. Methods
buildindex None Use given info in settings to build a new index commit None To be called after last update if you did not use auto commit when updating index. It will write all updates done to disk. To do it only once when updating will speed up the process. connecttocurrentrepo PrismRepo Return the current debprism3 repository object createindex None Will create a new index based on path or name if none exists. Will simply return if the index exists. datetimefromfields datetime Take a date and time in Prism form and return it as Python datetime class
Parameters
- date | a Prism date from a record
- time | a Prism time from a recordgetlastupdate tuple The last update date done on the index based on file time on the toc
Return dataetime, dateastxt, timeastxtrefreshindex None Refresh the current index with updated documents based in the settings removeindex bool Remove index files and remove directory for index so you can start over searchindex dict Search the index and return each url and title that have a match
Parameters
- search=None | what to search for
- maxret=20 | how many results max to returnupdateindex None This method will add or update content in the search database.
Parameters:
- title=None | title given when hit in search are returned
- url=None | unique id for finding the document with the hit
- content=None | content in document to index
- isnew=True | tell if this is a new document or not
- autocommit=True | auto commit the content to disk after updateHow to create a index object