<?php require "strus.php"; $queryphrase = "city"; $config = "path=storage"; $ctx = new StrusContext(); try { # Get a client for the storage: $storage = $ctx->createStorageClient($config); # Define the query analyzer to use: $analyzer = $ctx->createQueryAnalyzer(); $analyzer->addSearchIndexElement("word", "word", "word", array(array("stem", "en"), "lc", array("convdia", "en"))); # Define the query evaluation scheme: $queryeval = $ctx->createQueryEval(); # Here we define what query features decide, what is ranked for the result: $queryeval->addSelectionFeature("select"); # Here we define how we rank a document selected. We use the 'BM25' weighting scheme: $queryeval->addWeightingFunction("BM25", array("k1" => 0.75, "b" => 2.1, "avgdoclen" => 1000, ".match" => "seek")); # Now we define what attributes of the documents are returned and how they are build. # The functions that extract stuff from documents for presentation are called summarizers. # First we add a summarizer that extracts us the title of the document: $queryeval->addSummarizer("attribute", array("name" => "title")); # Then we add a summarizer that collects the sections that enclose the best matches # in a ranked document: $queryeval->addSummarizer("matchphrase", array("type" => "orig", "sentencesize" => 40, "windowsize" => 60, ".match" => "seek")); # Now we build the query to issue: $query = $queryeval->createQuery($storage); # First we analyze the query phrase to get the terms to find in the form as they are stored in the storage: $terms = $analyzer->analyzeField("word", $queryphrase); if (count($terms) == 0) { throw new Exception("query is empty");