### Get Started Status of PostingSource Source: https://xapian.org/docs/apidoc/html/classXapian_1_1ValueMapPostingSource-members.html Checks if the PostingSource has been initialized and started. This is an inline method. ```cpp get_started() const| Xapian::ValuePostingSource| inline ``` -------------------------------- ### Build and Install Xapian Core Source: https://xapian.org/docs/install.html Configure, build, and install the Xapian core library. Use `--prefix` to specify an installation directory, such as `/opt`. ```bash cd xapian-core- ./configure --prefix=/opt make sudo make install ``` -------------------------------- ### Example query string Source: https://xapian.org/docs/valueranges.html Example of user input syntax for range queries supported by the configured processors. ```text laptop $300..800 ..1.5kg ``` -------------------------------- ### Run Xapian Java Examples Source: https://xapian.org/docs/bindings/java Execute the compiled Java examples by specifying the JNI library path via the java.library.path system property. ```bash java -Djava.library.path=built -classpath built/xapian.jar:docs/examples \ SimpleIndex ./test.db index words like java java -Djava.library.path=built -classpath built/xapian.jar:docs/examples \ SimpleSearch ./test.db index words like java ``` -------------------------------- ### Compile Xapian Java Examples Source: https://xapian.org/docs/bindings/java Use javac to compile the SimpleIndex and SimpleSearch example classes with the Xapian JAR in the classpath. ```bash cd java javac -classpath built/xapian.jar:. docs/examples/SimpleIndex.java javac -classpath built/xapian.jar:. docs/examples/SimpleSearch.java ``` -------------------------------- ### Example Usage Source: https://xapian.org/docs/bindings/perl/Search/Xapian/ValueCountMatchSpy.html An example demonstrating how to use Search::Xapian::ValueCountMatchSpy to count value frequencies in search results. ```APIDOC ```perl use Search::Xapian qw(:all); my $db = Search::Xapian::Database->new( '[DATABASE DIR]' ); my $enq = $db->enquire( '[QUERY TERM]' ); my $spy = Search::Xapian::ValueCountMatchSpy->new(0); $enq->add_matchspy($spy); my $mset = $enq->get_mset(0, 10, 10000); print "Match spy registered " . $spy->get_total() . " documents\n"; my $end = $spy->values_end(); for (my $it = $spy->values_begin(); $it != $end; $it++) { print $it->get_termname() . " - " . $it->get_termfreq(); } ``` ``` -------------------------------- ### Install Xapian to Home Directory Source: https://xapian.org/docs/install.html Configure and install Xapian to a specified directory within your home directory if you lack root access. ```bash ./configure --prefix=/home/jenny/xapian-install ``` -------------------------------- ### Run unoconv in the background for HTML conversion Source: https://xapian.org/docs/omega/overview.html Start the unoconv listener in the background to efficiently convert documents to HTML using LibreOffice. This is recommended before indexing to avoid starting LibreOffice for every file. ```bash unoconv --listener & ``` -------------------------------- ### values_begin() Source: https://xapian.org/docs/apidoc/html/classXapian_1_1Document.html Starts iteration over the values in the document. ```APIDOC ## values_begin() ### Description Start iterating the values in this document. The values are returned in ascending numerical slot order. ### Response - **Returns** (ValueIterator) - An iterator for the document values. ``` -------------------------------- ### postlist_begin() Source: https://xapian.org/docs/apidoc/html/classXapian_1_1Database.html Starts iterating the postings of a term. ```APIDOC ## postlist_begin() ### Description Start iterating the postings of a term. An empty string acts as a special pseudo-term which indexes all the documents in the database with a wdf of 1. ### Parameters #### Query Parameters - **term** (std::string_view) - Required - The term to iterate the postings of. ### Response - **PostingIterator** - An iterator over the postings. ``` -------------------------------- ### Xapian::ValuePostingSource::init Source: https://xapian.org/docs/bindings/python/xapian.html Initializes the PostingSource to the start of the list of postings. ```APIDOC ## POST /Xapian/ValuePostingSource/init ### Description Set this PostingSource to the start of the list of postings. This is called automatically by the matcher prior to each query. ### Method POST ### Endpoint Xapian::ValuePostingSource::init(const Database &db_) ### Parameters #### Request Body - **db** (Database) - Required - The database which the PostingSource should iterate through. ``` -------------------------------- ### termlist_begin() Source: https://xapian.org/docs/apidoc/html/classXapian_1_1Document.html Starts iteration over the terms in the document. ```APIDOC ## termlist_begin() ### Description Start iterating the terms in this document. The terms are returned in ascending string order. ### Response - **Returns** (TermIterator) - An iterator for the document terms. ``` -------------------------------- ### Get Omega Version Source: https://xapian.org/docs/omega/omegascript.html Returns the version string of Omega, for example, "xapian-omega 1.2.6". ```OmegaScript $version ``` -------------------------------- ### Get Matching Terms for a Document in Ruby Source: https://xapian.org/docs/bindings/ruby/rdocs/Xapian/Enquire.html Use this method to retrieve terms that match a given document. The document can be specified as a Xapian::DocID or a Xapian::MSetIterator. Requires the Xapian library to be installed. ```Ruby # File xapian.rb, line 204 def matching_terms(document, &block) Xapian._safelyIterate(self._dangerous_matching_terms_begin(document), self._dangerous_matching_terms_end(document), lambda { |item| Xapian::Term.new(item.term, item.wdf) }, &block) end ``` -------------------------------- ### Python simplesearch.py Example Source: https://xapian.org/docs/bindings/python3/_sources/examples.rst.txt Demonstrates how to perform a search using the Xapian Python bindings. Ensure the index is set up before running. ```python import sys import os from xapian_bindings import XapianDB def main(): if len(sys.argv) < 3: print("Usage: %s " % sys.argv[0]) sys.exit(1) dbpath = sys.argv[1] query = sys.argv[2] if not os.path.exists(dbpath): print("Error: Database path '%s' does not exist." % dbpath) sys.exit(1) db = XapianDB(dbpath) print("Searching for '%s' in database '%s'" % (query, dbpath)) results = db.search(query) print("Found %d documents:" % len(results)) for docid, rank in results: print(" DocID: %d, Rank: %f" % (docid, rank)) if __name__ == "__main__": main() ``` -------------------------------- ### Initialize and Use QueryParser Source: https://xapian.org/docs/bindings/perl/Search/Xapian/QueryParser.html Demonstrates initializing a QueryParser with a database, setting a stemmer and default operator, and parsing a query string. ```perl use Search::Xapian qw/:standard/; my $qp = new Search::Xapian::QueryParser( [$database] ); $qp->set_stemmer(new Search::Xapian::Stem("english")); $qp->set_default_op(OP_AND); $database->enquire($qp->parse_query('a NEAR word OR "a phrase" NOT (too difficult) +eh')); ``` -------------------------------- ### Example field-based range query Source: https://xapian.org/docs/valueranges.html Example of a field-prefixed range query string. ```text created:1/1/1999..1/1/2003 ``` -------------------------------- ### init Source: https://xapian.org/docs/apidoc/html/classXapian_1_1PostingSource.html Initializes the posting source with a database reference. ```APIDOC ## init() ### Description Initializes the posting source. This is an older method superseded by reset(). ### Method POST ### Parameters #### Request Body - **db** (Database) - Required - The database reference. ``` -------------------------------- ### Italian Attached Pronoun Examples Source: https://xapian.org/docs/stemming.html Examples of Italian pronouns attaching to verb forms. ```text scrivendole = scrivendo (writing) + le (to her) mandarglielo = mandare (to give) + glielo (it to him) ``` -------------------------------- ### Python simpleexpand.py Example Source: https://xapian.org/docs/bindings/python3/_sources/examples.rst.txt Demonstrates query expansion using the Xapian Python bindings. This script searches for a query and then expands it based on related terms. ```python import sys import os from xapian_bindings import XapianDB def main(): if len(sys.argv) < 3: print("Usage: %s " % sys.argv[0]) sys.exit(1) dbpath = sys.argv[1] query = sys.argv[2] if not os.path.exists(dbpath): print("Error: Database path '%s' does not exist." % dbpath) sys.exit(1) db = XapianDB(dbpath) print("Searching for '%s' and expanding query in database '%s'" % (query, dbpath)) # Perform an initial search to get related terms initial_results = db.search(query, max_results=10) related_terms = [] for docid, rank in initial_results: # Get terms from the document (simplified) doc = db.get_document(docid) terms = doc.get_terms() related_terms.extend(terms) # Create an expanded query (simple example: add top 5 related terms) unique_related_terms = list(set(related_terms)) expanded_query_str = query for term in unique_related_terms[:5]: expanded_query_str += " OR %s" % term print("Expanded query: '%s'" % expanded_query_str) expanded_results = db.search(expanded_query_str) print("Found %d documents with expanded query:" % len(expanded_results)) for docid, rank in expanded_results: print(" DocID: %d, Rank: %f" % (docid, rank)) if __name__ == "__main__": main() ``` -------------------------------- ### init() Source: https://xapian.org/docs/apidoc/html/classXapian_1_1CoordWeight.html Allow the subclass to perform any initialisation it needs to. ```APIDOC ## init() ### Description Allow the subclass to perform any initialisation it needs to. ### Parameters - **factor** (double) - Any scaling factor (e.g. from OP_SCALE_WEIGHT). ``` -------------------------------- ### Get Term Frequency Estimate Source: https://xapian.org/docs/apidoc/html/classXapian_1_1ValueMapPostingSource-members.html Gets the estimated term frequency for the current document. This is a virtual method. ```cpp get_termfreq_est() const| Xapian::ValuePostingSource| virtual ``` -------------------------------- ### Python simpleindex.py Example Source: https://xapian.org/docs/bindings/python3/_sources/examples.rst.txt Shows how to add documents to a Xapian database using the Python bindings. This script creates or opens a database and indexes provided documents. ```python import sys import os from xapian_bindings import XapianDB def main(): if len(sys.argv) < 3: print("Usage: %s " % sys.argv[0]) sys.exit(1) dbpath = sys.argv[1] doc_text = sys.argv[2] # Create database if it doesn't exist if not os.path.exists(dbpath): print("Creating database at '%s'" % dbpath) db = XapianDB(dbpath, create=True) else: print("Opening database at '%s'" % dbpath) db = XapianDB(dbpath) print("Indexing document: '%s'" % doc_text) docid = db.add_document(doc_text) print("Document indexed with ID: %d" % docid) if __name__ == "__main__": main() ``` -------------------------------- ### Get Minimum Term Frequency Source: https://xapian.org/docs/apidoc/html/classXapian_1_1ValueMapPostingSource-members.html Gets the minimum possible term frequency for the current document. This is a virtual method. ```cpp get_termfreq_min() const| Xapian::ValuePostingSource| virtual ``` -------------------------------- ### Initialize and Use ValueCountMatchSpy Source: https://xapian.org/docs/bindings/perl/Search/Xapian/ValueCountMatchSpy.html Demonstrates how to create a database, perform a search, add a ValueCountMatchSpy to the query, retrieve results, and then iterate through the tallied values and their frequencies. Ensure the database directory and query term are correctly specified. ```perl use Search::Xapian qw(:all); my $db = Search::Xapian::Database->new( '[DATABASE DIR]' ); my $enq = $db->enquire( '[QUERY TERM]' ); my $spy = Search::Xapian::ValueCountMatchSpy->new(0); $enq->add_matchspy($spy); my $mset = $enq->get_mset(0, 10, 10000); print "Match spy registered " . $spy->get_total() . " documents\n"; my $end = $spy->values_end(); for (my $it = $spy->values_begin(); $it != $end; $it++) { print $it->get_termname() . " - " . $it->get_termfreq(); } ``` -------------------------------- ### Get Maximum Term Frequency Source: https://xapian.org/docs/apidoc/html/classXapian_1_1ValueMapPostingSource-members.html Gets the maximum possible term frequency for the current document. This is a virtual method. ```cpp get_termfreq_max() const| Xapian::ValuePostingSource| virtual ``` -------------------------------- ### Database Initialization Source: https://xapian.org/docs/apidoc/html/classXapian_1_1Database.html Methods for constructing and opening a Xapian database. ```APIDOC ## Constructor Xapian::Database ### Description Constructs a new Database object. Can be initialized empty or by opening a database from a file system path. ### Parameters #### Request Body - **path** (std::string_view) - Optional - Filing system path to open database from. - **flags** (int) - Optional - Bitwise-or of Xapian::DB_* constants. ### Response - **Database** (Object) - A reference counted handle to the database. ``` -------------------------------- ### Initialize ValueMapPostingSource Source: https://xapian.org/docs/bindings/python3/_modules/xapian.html Constructs a ValueMapPostingSource to map document values from a specified slot to weights. Use this to assign custom weights based on document content. ```python ValueMapPostingSource(slot_) ``` -------------------------------- ### Get current Unicode character Source: https://xapian.org/docs/apidoc/html/classXapian_1_1Utf8Iterator.html Dereferences the iterator to get the Unicode character value at the current position. This operation is noexcept. ```cpp unsigned operator* () const noexcept ``` -------------------------------- ### Example 'file' Utility Output Source: https://xapian.org/docs/omega/newformat.html The 'file' utility's output indicates the detected MIME type of a file. This output is used to verify or determine the correct MIME type for configuration. ```text example.fb2: text/xml ``` -------------------------------- ### Perform Query Expansion with Xapian Source: https://xapian.org/docs/bindings/csharp/examples/SimpleExpand.cs Demonstrates initializing a database, parsing queries, and retrieving expansion terms. Requires the Xapian C# bindings to be properly configured in the project environment. ```csharp // Simple example program demonstrating query expansion. // // Copyright (c) 2003 James Aylett // Copyright (c) 2004,2006,2007 Olly Betts // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see // . using System; class SimpleExpand { public static void Main(string[] argv) { // We require at least two command line arguments. if (argv.Length < 2) { Console.Error.WriteLine("Usage: SimpleExpand PATH_TO_DATABASE QUERY [-- [DOCID...]]"); Environment.Exit(1); } try { // Open the database for searching. Xapian.Database database = new Xapian.Database(argv[0]); // Start an enquire session. Xapian.Enquire enquire = new Xapian.Enquire(database); // Create an RSet to add the listed docids to. Xapian.RSet rset = new Xapian.RSet(); // Combine command line arguments up to "--" with spaces between // them, so that simple queries don't have to be quoted at the // shell level. string query_string = argv[1]; for (int i = 2; i < argv.Length; ++i) { if (argv[i] == "--") { while (++i < argv.Length) { rset.AddDocument(Convert.ToUInt32(argv[i])); } break; } query_string += ' '; query_string += argv[i]; } // Parse the query string to produce a Xapian::Query object. Xapian.QueryParser qp = new Xapian.QueryParser(); Xapian.Stem stemmer = new Xapian.Stem("english"); qp.SetStemmer(stemmer); qp.SetDatabase(database); qp.SetStemmingStrategy(Xapian.QueryParser.stem_strategy.STEM_SOME); Xapian.Query query = qp.ParseQuery(query_string); Console.WriteLine("Parsed query is: " + query.GetDescription()); // Find the top 10 results for the query. enquire.SetQuery(query); Xapian.MSet matches = enquire.GetMSet(0, 10, rset); // Display the results. Console.WriteLine("{0} results found.", matches.GetMatchesEstimated()); Console.WriteLine("Matches 1-{0}:", matches.Size()); Xapian.MSetIterator m = matches.Begin(); while (m != matches.End()) { Console.WriteLine("{0}: {1}% docid={2} [{3}]\n", m.GetRank() + 1, m.GetPercent(), m.GetDocId(), m.GetDocument().GetData()); ++m; } // If no relevant docids were given, invent an RSet containing the // top 5 matches (or all the matches if there are less than 5). if (rset.Empty()) { int c = 5; Xapian.MSetIterator i = matches.Begin(); while (c-- > 0 && i != matches.End()) { rset.AddDocument(i.GetDocId()); ++i; } } // Generate an ESet containing terms that the user might want to // add to the query. Xapian.ESet eset = enquire.GetESet(10, rset); Console.WriteLine(eset.Size()); // List the terms. for (Xapian.ESetIterator t = eset.Begin(); t != eset.End(); ++t) { Console.WriteLine("{0}: weight = {1}", t.GetTerm(), t.GetWeight()); } } catch (Exception e) { Console.Error.WriteLine("Exception: " + e.ToString()); Environment.Exit(1); } } } ``` -------------------------------- ### Non-Pythonic Iterator Loop Example Source: https://xapian.org/docs/bindings/python/introduction.html This example shows the older, non-Pythonic way of iterating through an MSet using `begin()`, `next()`, and `end()`. ```python m=mset.begin() while m!=mset.end(): # do something m.next() ``` -------------------------------- ### Basic Xapian Search Query in Perl Source: https://xapian.org/docs/bindings/perl/Xapian.html Demonstrates how to initialize a query parser, parse a query string, open a database, and perform a search, then iterate over the results. Ensure the query string and database directory are correctly specified. ```perl use Xapian; my $parser = Xapian::QueryParser->new(); my $query = $parser->parse_query( '[QUERY STRING]' ); my $db = Xapian::Database->new( '[DATABASE DIR]' ); my $enq = $db->enquire(); printf "Running query '%s'\n", $query->get_description(); $enq->set_query( $query ); my @matches = $enq->matches(0, 10); print scalar(@matches) . " results found\n"; foreach my $match ( @matches ) { my $doc = $match->get_document(); printf "ID %d %d%% [ %s ]\n", $match->get_docid(), $match->get_percent(), $doc->get_data(); } ``` -------------------------------- ### Xapian Record Formatting Example Source: https://xapian.org/docs/omega/scriptindex.html Example of a record with multiple fields, demonstrating how to handle multi-line values by escaping newlines with an equals sign ('='). ```xapian id=ghq147 title=Sample Record value=This is a multi-line =value. Note how each newline =is escaped. format=HTML ``` -------------------------------- ### Substring Extraction Source: https://xapian.org/docs/omega/omegascript.html Extracts a substring from a given string based on start position and length. Negative start counts from the end. Negative length specifies bytes to omit from the end. ```xapian $substr{hello,-1} ``` ```xapian $substr{example,2,-2} ``` ```xapian $substr{STRING,START,LENGTH} ``` ```xapian $substr{STRING,START} ``` -------------------------------- ### Initialize and Use Xapian::QueryParser Source: https://xapian.org/docs/bindings/perl/Xapian/QueryParser.html Demonstrates initializing a QueryParser with a database, setting a stemmer and default operator, and parsing a query string. ```perl use Xapian qw/:standard/; my $qp = new Xapian::QueryParser( [$database] ); $qp->set_stemmer(new Xapian::Stem("english")); $qp->set_default_op(OP_AND); $database->enquire($qp->parse_query('a NEAR word OR "a phrase" NOT (too difficult) +eh')); ``` -------------------------------- ### get_termfreq() Source: https://xapian.org/docs/apidoc/html/classXapian_1_1MSet.html Gets the term frequency of a given term within the context of the MSet's associated database. This is an efficient way to get the document count for a term that was part of the original query. ```APIDOC ## get_termfreq() ### Description Get the term frequency of a term. Returns the number of documents which the term occurs in. This considers all documents in the database being searched, so gives the same answer as `db.get_termfreq(term)` (but is more efficient for query terms as it returns a value cached during the search.) ### Method `const` ### Parameters - **term** (`std::string_view`) - The term to get the frequency for. ### Return Value `Xapian::doccount` - The number of documents containing the term. ### Notes - Since 2.0.0, this method returns 0 if called on an MSet which is not associated with a database. In earlier versions, `Xapian::InvalidOperationError` was thrown. ``` -------------------------------- ### Initialize PostingSource Source: https://xapian.org/docs/apidoc/html/classXapian_1_1ValueMapPostingSource-members.html Initializes the PostingSource with a given Database. This is a virtual method. ```cpp init(const Database &db)| Xapian::PostingSource| virtual ``` -------------------------------- ### Xapian::QueryParser - Constructor and Basic Configuration Source: https://xapian.org/docs/bindings/perl/Xapian/QueryParser.html Demonstrates how to create a QueryParser object and configure basic settings like stemming and default operators. ```APIDOC ## Xapian::QueryParser - Constructor and Basic Configuration ### Description This section covers the instantiation of the `Xapian::QueryParser` object and the configuration of its core behaviors, such as setting a stemmer, a default operator, and a stopper. ### Methods #### `new( )` * **Description**: QueryParser constructor. * **Parameters**: - **database** (Xapian::Database) - The database object to associate with the parser. #### `set_stemmer( )` * **Description**: Set the Xapian::Stem object to be used for stemming query terms. * **Parameters**: - **stemmer** (Xapian::Stem) - The stemmer object to use. #### `set_stopper( )` * **Description**: Set the Xapian::Stopper object to be used for identifying stopwords. * **Parameters**: - **stopper** (Xapian::Stopper) - The stopper object to use. #### `set_default_op( )` * **Description**: Set the default operator used to combine non-filter query items when no explicit operator is used. Useful values include `OP_OR` (default) and `OP_AND`. * **Parameters**: - **operator** (Xapian::Query::Oper) - The default operator (e.g., `OP_AND`, `OP_OR`). #### `get_default_op()` * **Description**: Returns the current default operator. ### Request Example ```perl use Xapian qw/:standard/; my $database = ...; # Assume $database is a valid Xapian::Database object my $qp = Xapian::QueryParser->new($database); $qp->set_stemmer(Xapian::Stem->new('english')); $qp->set_default_op(OP_AND); ``` ``` -------------------------------- ### Database() Constructor (File Descriptor) Source: https://xapian.org/docs/apidoc/html/classXapian_1_1Database.html Opens a single-file Xapian Database using a provided file descriptor. The database is opened starting at the current file offset. ```APIDOC ## Database() (File Descriptor) ### Description Opens a single-file Database given a file descriptor open on it. Xapian looks starting at the current file offset, allowing a single file database to be easily embedded within another file. ### Method `Database()` (constructor) ### Parameters #### Path Parameters - **fd** (int) - Required - File descriptor for the file. Xapian takes ownership of this and will close it when the database is closed. - **flags** (int) - Optional - Bitwise-or of Xapian::DB_* constants. ### Exceptions - **Xapian::DatabaseOpeningError** - if the specified database cannot be opened - **Xapian::DatabaseVersionError** - if the specified database has a format too old or too new to be supported. ``` -------------------------------- ### Importing Xapian Module Source: https://xapian.org/docs/bindings/perl/Xapian.html Demonstrates how to import the Xapian module, with a fallback to Search::Xapian if Xapian is not installed. It also explains the purpose of Xapian::search_xapian_compat(). ```APIDOC ## Importing Either Module If you want your code to use either this module or Search::Xapian depending what's installed, then instead of `use Search::Xapian (':all');` you can use: ```perl BEGIN { eval { require Xapian; Xapian->import(':all'); Xapian::search_xapian_compat(); }; if ($@) { require Search::Xapian; Search::Xapian->import(':all'); } } ``` If you just `use Search::Xapian;` then the `import()` calls aren't needed. The `Xapian::search_xapian_compat()` call sets up aliases in the `Search::Xapian` namespace so you can write code which refers to `Search::Xapian` but can actually use this module instead. ``` -------------------------------- ### reset() Source: https://xapian.org/docs/apidoc/html/classXapian_1_1FixedWeightPostingSource.html Sets the PostingSource to the start of the list of postings. ```APIDOC ## reset() ### Description Set this PostingSource to the start of the list of postings. This is called automatically by the matcher prior to each query being processed. If a PostingSource is used for multiple searches, reset() will therefore be called multiple times, and must handle this by using the database passed in the most recent call. Reimplemented from Xapian::PostingSource. ### Method void ### Endpoint N/A (Method within a class) ### Parameters #### Path Parameters - **db** (const Database &) - Required - The database which the PostingSource should iterate through. - **shard_index** (Xapian::doccount) - Required - The 0-based index indicating which shard in a multi-database db is. ### Request Example None ### Response None (This method modifies the internal state and does not return a value directly). ``` -------------------------------- ### Configure and Build Omega with Specific Xapian Config Source: https://xapian.org/docs/install.html Build the Omega component, specifying the path to the `xapian-config` script if it's not in your PATH or if multiple Xapian installations exist. ```bash cd xapian-omega- ./configure --prefix=/opt XAPIAN_CONFIG=/opt/bin/xapian-config make sudo make install ``` -------------------------------- ### Registry.get_key_maker() Method Source: https://xapian.org/docs/bindings/python3/xapian.html Gets a KeyMaker given its name. ```APIDOC ## Registry.get_key_maker() ### Description Get a KeyMaker given a name. ### Parameters - **name** (std::string_view) - The name of the KeyMaker to find. ### Returns const Xapian::KeyMaker * - An object with the requested name, or NULL if the KeyMaker could not be found. The returned object must not be deleted by the caller. Added in Xapian 2.0.0. ``` -------------------------------- ### GET /xapian/document/termlist_count Source: https://xapian.org/docs/bindings/python/genindex.html Returns the count of terms in a document. ```APIDOC ## GET /xapian/document/termlist_count ### Description Returns the number of terms present in the document. ### Method GET ### Endpoint xapian.Document.termlist_count() ``` -------------------------------- ### GET name() Source: https://xapian.org/docs/apidoc/html/classXapian_1_1DPHWeight.html Returns the name of the weighting scheme. ```APIDOC ## GET name() ### Description Return the name of this weighting scheme, used for registration and creation via Weight::create(). ### Method GET ### Endpoint Xapian::DPHWeight::name() ### Response - **return** (std::string) - The name of the weighting scheme. ``` -------------------------------- ### Constructor: Open or Create WritableDatabase Source: https://xapian.org/docs/apidoc/html/classXapian_1_1WritableDatabase.html Initializes a WritableDatabase instance by opening an existing database or creating a new one at the specified path. ```APIDOC ## Constructor: WritableDatabase(std::string_view path, int flags, int block_size) ### Description Creates or opens a Xapian database for both reading and writing. ### Parameters #### Path Parameters - **path** (std::string_view) - Required - Filing system path for the database. #### Request Body - **flags** (int) - Optional - A bitwise-or combination of constants (e.g., DB_CREATE_OR_OPEN, DB_BACKEND_GLASS, DB_NO_SYNC). - **block_size** (int) - Optional - The block size in bytes to use when creating a new database (default 8192). ### Exceptions - **Xapian::DatabaseLockError** - Thrown if the write lock could not be acquired. - **Xapian::DatabaseOpeningError** - Thrown if the database cannot be opened. - **Xapian::DatabaseVersionError** - Thrown if the database format is unsupported. ``` -------------------------------- ### RangeProcessor.release() Method Source: https://xapian.org/docs/bindings/python3/xapian.html Starts reference counting for a RangeProcessor object. ```APIDOC ## RangeProcessor.release() ### Description Start reference counting this object. const RangeProcessor * Xapian::RangeProcessor::release() const You can transfer ownership of a dynamically allocated RangeProcessor object to Xapian by calling release() and then passing the object to a Xapian method. Xapian will arrange to delete the object once it is no longer required. ``` -------------------------------- ### positionlist_begin() Source: https://xapian.org/docs/apidoc/html/classXapian_1_1Database.html Starts iterating positions for a specific term in a document. ```APIDOC ## positionlist_begin() ### Description Start iterating positions for a term in a document. ### Parameters #### Query Parameters - **did** (Xapian::docid) - Required - The document id of the document. - **term** (std::string_view) - Required - The term to iterate positions for. ### Response - **PositionIterator** - An iterator over the positions of the term in the document. ``` -------------------------------- ### Implement ValueWeightPostingSource methods Source: https://xapian.org/docs/bindings/python/xapian.html Methods for defining custom posting sources that derive weights from document values. ```cpp double Xapian::ValueWeightPostingSource::get_weight() const ``` ```cpp void Xapian::ValueWeightPostingSource::init(const Database &db_) ``` ```cpp std::string Xapian::ValueWeightPostingSource::name() const ``` -------------------------------- ### Registry.get_posting_source() Method Source: https://xapian.org/docs/bindings/python3/xapian.html Gets a posting source given its name. ```APIDOC ## Registry.get_posting_source() ### Description Get a posting source given a name. ### Parameters - **name** (std::string_view) - The name of the posting source to find. ### Returns const Xapian::PostingSource * ``` -------------------------------- ### QueryParser Constructor and Configuration Source: https://xapian.org/docs/bindings/perl/Search/Xapian/QueryParser.html Initialize and configure the Search::Xapian::QueryParser object. ```APIDOC ## QueryParser Constructor and Configuration ### Description Initializes a new QueryParser object and allows configuration of stemming, default operators, and stopwords. ### Methods #### `new( )` * **Description**: QueryParser constructor. * **Parameters**: - **database** (Search::Xapian::Database) - The database to associate with the parser. #### `set_stemmer( )` * **Description**: Set the Search::Xapian::Stem object for stemming query terms. * **Parameters**: - **stemmer** (Search::Xapian::Stem) - The stemmer object to use. #### `set_stemming_strategy( )` * **Description**: Set the stemming strategy. * **Parameters**: - **strategy** (string) - Valid values are `STEM_ALL`, `STEM_SOME`, `STEM_NONE`. #### `set_stopper( )` * **Description**: Set the Search::Xapian::Stopper object for identifying stopwords. * **Parameters**: - **stopper** (Search::Xapian::Stopper) - The stopper object to use. #### `set_default_op( )` * **Description**: Set the default operator for combining non-filter query items when no explicit operator is used. * **Parameters**: - **operator** (constant) - Useful values include `OP_OR` (default), `OP_AND`, `OP_NEAR`, `OP_PHRASE`. #### `get_default_op()` * **Description**: Returns the current default operator. #### `set_database( )` * **Description**: Pass a Search::Xapian::Database object used to check term existence. * **Parameters**: - **database** (Search::Xapian::Database) - The database object. #### `get_description()` * **Description**: Returns a string describing this object. ``` -------------------------------- ### Constructor: new Source: https://xapian.org/docs/bindings/perl/Search/Xapian/BoolWeight.html Initializes a new instance of the Boolean Weighting scheme. ```APIDOC ## Constructor: new ### Description Creates a new instance of the Boolean Weighting scheme. This scheme assigns a weight of 0 to all documents. ### Method Constructor ### Parameters None ``` -------------------------------- ### Registry.get_match_spy() Method Source: https://xapian.org/docs/bindings/python3/xapian.html Gets a match spy given its name. ```APIDOC ## Registry.get_match_spy() ### Description Get a match spy given a name. ### Parameters - **name** (std::string_view) - The name of the match spy to find. ### Returns const Xapian::MatchSpy * - An object with the requested name, or NULL if the match spy could not be found. The returned object is owned by the registry and so must not be deleted by the caller. ``` -------------------------------- ### Basic OmegaScript Command Usage Source: https://xapian.org/docs/omega/omegascript.html Demonstrates the basic syntax of OmegaScript commands within an HTML template, including variable substitution. ```html Sample

You searched for '$html{$query}'.

``` -------------------------------- ### Registry.get_lat_long_metric() Method Source: https://xapian.org/docs/bindings/python3/xapian.html Gets a lat-long metric given its name. ```APIDOC ## Registry.get_lat_long_metric() ### Description Get a lat-long metric given a name. ### Returns const Xapian::LatLongMetric * - The returned metric is owned by the registry object. Returns NULL if the metric could not be found. ``` -------------------------------- ### GET /database/spelling-suggestion Source: https://xapian.org/docs/bindings/python3/xapian.html Suggests a spelling correction for a given word. ```APIDOC ## GET /database/spelling-suggestion ### Description Suggest a spelling correction for a potentially misspelled word. ### Method GET ### Endpoint /database/spelling-suggestion ### Parameters #### Query Parameters - **word** (string) - Required - The potentially misspelled word. - **max_edit_distance** (unsigned) - Optional - Maximum edits allowed (default: 2). ### Response #### Success Response (200) - **suggestion** (string) - The suggested spelling correction. ``` -------------------------------- ### Initialize MultiValueSorter for Search Results Source: https://xapian.org/docs/bindings/perl/Search/Xapian/MultiValueSorter.html Demonstrates how to instantiate a MultiValueSorter with specific value slots and apply it to an Enquire object. ```perl use Search::Xapian; my $db = new Search::Xapian::Database("/path/to/db"); my $enq = new Search::Xapian::Enquire($db); my $sorter = new Search::Xapian::MultiValueSorter(1, 3, 5); $enq->set_sort_by_key($sorter); ``` -------------------------------- ### GET /database/document/{did} Source: https://xapian.org/docs/bindings/python3/xapian.html Retrieves a specific document from the database by its ID. ```APIDOC ## GET /database/document/{did} ### Description Get a document from the database using its document ID. ### Method GET ### Endpoint /database/document/{did} ### Parameters #### Path Parameters - **did** (Xapian::docid) - Required - The document ID of the document to be retrieved. #### Query Parameters - **flags** (unsigned) - Optional - Bitwise-or-ed flags (default: 0). ### Response #### Success Response (200) - **document** (Xapian::Document) - The requested document object. ``` -------------------------------- ### Perform a search with Xapian Python bindings Source: https://xapian.org/docs/bindings/python3/examples.html Demonstrates opening a database, parsing a query string with stemming, and retrieving search results. ```python #!/usr/bin/env python # # Simple command-line search script. # # Copyright (C) 2003 James Aylett # Copyright (C) 2004,2007,2009,2013 Olly Betts # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see # . import sys import xapian # We require at least two command line arguments. if len(sys.argv) < 3: print("Usage: %s PATH_TO_DATABASE QUERY" % sys.argv[0], file=sys.stderr) sys.exit(1) try: # Open the database for searching. database = xapian.Database(sys.argv[1]) # Start an enquire session. enquire = xapian.Enquire(database) # Combine the rest of the command line arguments with spaces between # them, so that simple queries don't have to be quoted at the shell # level. query_string = str.join(' ', sys.argv[2:]) # Parse the query string to produce a Xapian::Query object. qp = xapian.QueryParser() stemmer = xapian.Stem("english") qp.set_stemmer(stemmer) qp.set_database(database) qp.set_stemming_strategy(xapian.QueryParser.STEM_SOME) query = qp.parse_query(query_string) print("Parsed query is: %s" % str(query)) # Find the top 10 results for the query. enquire.set_query(query) matches = enquire.get_mset(0, 10) # Display the results. print("%i results found." % matches.get_matches_estimated()) print("Results 1-%i:" % matches.size()) for m in matches: print("%i: %i%% docid=%i [%s]" % (m.rank + 1, m.percent, m.docid, m.document.get_data().decode('utf-8'))) except Exception as e: print("Exception: %s" % str(e), file=sys.stderr) sys.exit(1) ``` -------------------------------- ### GET /database/doccount Source: https://xapian.org/docs/bindings/python3/xapian.html Retrieves the total number of documents in the database. ```APIDOC ## GET /database/doccount ### Description Get the number of documents in the database. ### Method GET ### Endpoint /database/doccount ### Response #### Success Response (200) - **count** (Xapian::doccount) - The total number of documents. ``` -------------------------------- ### Perform a basic search query with Search::Xapian Source: https://xapian.org/docs/bindings/perl/Search/Xapian.html Initializes a database connection, executes a query, and iterates through the resulting matches to display document data. ```perl use Search::Xapian; my $db = Search::Xapian::Database->new( '[DATABASE DIR]' ); my $enq = $db->enquire( '[QUERY TERM]' ); printf "Running query '%s'\n", $enq->get_query()->get_description(); my @matches = $enq->matches(0, 10); print scalar(@matches) . " results found\n"; foreach my $match ( @matches ) { my $doc = $match->get_document(); printf "ID %d %d%% [ %s ]\n", $match->get_docid(), $match->get_percent(), $doc->get_data(); } ``` -------------------------------- ### GET /xapian/database/termlist Source: https://xapian.org/docs/bindings/python/genindex.html Retrieves the term list from a database or document. ```APIDOC ## GET /xapian/database/termlist ### Description Retrieves the list of terms associated with a database or a document. ### Method GET ### Endpoint xapian.Database.termlist() or xapian.Document.termlist() ``` -------------------------------- ### Perform a simple index with Xapian Source: https://xapian.org/docs/bindings/python/_sources/examples.rst.txt Demonstrates basic document indexing functionality using the Xapian Python bindings. ```python .. literalinclude :: examples/simpleindex.py :language: python :emphasize-lines: 12,15-18 :linenos: ``` -------------------------------- ### get_wdfdocmax Source: https://xapian.org/docs/apidoc/html/classXapian_1_1Database.html Get the maximum wdf value in a specified document. ```APIDOC ## GET /api/database/wdfdocmax ### Description Get the maximum wdf value in a specified document. ### Method GET ### Endpoint /api/database/wdfdocmax ### Parameters #### Query Parameters - **did** (docid) - Required - The document id of the document. ### Response #### Success Response (200) - **termcount** (integer) - The maximum wdf value for the document. ### Response Example { "termcount": 5 } ``` -------------------------------- ### GET /get_spelling_suggestion Source: https://xapian.org/docs/apidoc/html/classXapian_1_1Database.html Suggests a spelling correction for a given word. ```APIDOC ## GET /get_spelling_suggestion ### Description Suggest a spelling correction for a potentially misspelled word. ### Parameters #### Query Parameters - **word** (std::string_view) - Required - The potentially misspelled word. - **max_edit_distance** (unsigned) - Optional - Only consider words which are at most this many edits away (default: 2). ``` -------------------------------- ### Constructing Xapian Queries in Tcl Source: https://xapian.org/docs/bindings/tcl8 Demonstrates creating complex queries using lists of terms and sub-queries with the Xapian::Query constructor. ```tcl set terms [list "hello" "world"] xapian::Query subq $xapian::Query_OP_AND $terms xapian::Query bar_term "bar" 2 xapian::Query query $xapian::Query_OP_AND [list subq "foo" bar_term] ``` -------------------------------- ### GET /get_query Source: https://xapian.org/docs/apidoc/html/classXapian_1_1Enquire.html Retrieves the currently set query object. ```APIDOC ## GET /get_query ### Description Get the currently set query. If set_query() is not called before calling get_query(), then the default query Xapian::MatchNothing will be returned. ``` -------------------------------- ### Perform a simple query expansion with Xapian Source: https://xapian.org/docs/bindings/python/_sources/examples.rst.txt Demonstrates basic query expansion functionality using the Xapian Python bindings. ```python .. literalinclude :: examples/simpleexpand.py :language: python :emphasize-lines: 12,15-18 :linenos: ```