[Doxygen-users] Extending syntax of external searches.
Brought to you by:
dimitri
From: Alex F. <a....@la...> - 2017-05-09 11:13:53
|
Hi, I thought I would share this with other doxygen users. I recently moved my site to using "external searching" ( see http://www.stack.nl/~dimitri/doxygen/manual/extsearch.html ) . I noticed that the xapian library used by doxygen can provide more advance searching than is enabled by default in doxygen, so I modified addon/doxysearch/doxysearch.cpp to take advantage of it. In the main routine, I replaced the lines : > Xapian::Query query; > std::vector<std::string> words = split(searchFor,' '); > for (std::vector<std::string>::const_iterator it=words.begin();it!=words.end();++it) > { > query = Xapian::Query(Xapian::Query::OP_OR,query,Xapian::Query(*it)); > } with > std::vector<std::string> words = split(searchFor,' '); > Xapian::QueryParser parser; > parser.set_database(db); > parser.set_default_op(Xapian::Query::OP_AND); > parser.set_stemming_strategy(Xapian::QueryParser::STEM_ALL); > Xapian::termcount max_expansion=100; > //parser.set_max_wildcard_expansion(max_expansion,Xapian::Query::WILDCARD_LIMIT_MOST_FREQUENT); > parser.set_max_wildcard_expansion(max_expansion); > Xapian::Query query=parser.parse_query(searchFor,Xapian::QueryParser::FLAG_DEFAULT|Xapian::QueryParser::FLAG_WILDCARD); which gives me "stemmed" searches, wildcarding, and all terms are ANDed by default . The maximum wildcard expansion doesn't appear to work however, but this does not appear to be a problem for me. I have xapian 1.2.22 on my system which is about 18 months old. Then, to help my users, I modified src/translator_en.h so that search results include a link to a document describing the available search syntax. > virtual QCString trSearchResults(int numDocuments) > { > QCString Prompt("<BR> <A HREF=http://mywebserver/QueryParserSyntax.html> See here for details of available search syntax. > </A>"); > > if (numDocuments==0) > { > return "Sorry, no documents matching your query."+Prompt; } > else if (numDocuments==1) > { > return "Found <b>1</b> document matching your query."+Prompt; > } > else > { > return "Found <b>$num</b> documents matching your query. Showing best matches first."+Prompt ; > } > } I didn't attempt to translate this into all the other 43 available languages however! The document QueryParserSyntax.html is a modified version of https://xapian.org/docs/queryparser.html with just the parts relevant to my setup included. Hope this helps someone else. |