3 #include <Poco/AutoPtr.h>
4 #include <Poco/String.h>
20 :
inherited(),
SphinxNodeOptions(nodeName_, 0, homeDir_, indexName_), searcher(*this, startSearchd_, stopSearchd_), indexer(*this),
21 loaded(false), checkIncomingDocuments(false), packIncomingDocuments(false), minNumberFieldsPacking(0),
22 logger(), messagesCollection(message_const::
messages), message(messagesCollection),
23 matchMode(SPH_MATCH_EXTENDED2), sortMode(SPH_SORT_RELEVANCE), rankingMode(SPH_RANK_DEFAULT), rankExpression(
"")
25 if (!homeDir_.empty() && !indexName_.empty())
39 :
inherited(),
SphinxNodeOptions(nodeName_, nodeNumber_, homeDir_, indexName_), searcher(*this, startSearchd_, stopSearchd_), indexer(*this),
40 loaded(false), checkIncomingDocuments(false), packIncomingDocuments(false), minNumberFieldsPacking(0),
41 logger(), messagesCollection(message_const::
messages), message(messagesCollection),
42 matchMode(SPH_MATCH_EXTENDED2), sortMode(SPH_SORT_RELEVANCE), rankingMode(SPH_RANK_DEFAULT), rankExpression(
"")
44 if (!homeDir_.empty() && !indexName_.empty())
70 return logger.
logMsg(isReset);
90 size_t pos = in.find(
':');
91 if (pos==std::string::npos)
94 outPort = std::stoul(Poco::trim(in));
98 outHost = Poco::trim(std::string(in, 0, pos));
99 outPort = std::stoul(Poco::trim(std::string(in, pos+1)));
105 rankingMode=rankingMode_;
106 if (!rankExpression_.empty())
107 rankExpression = rankExpression_;
125 unsigned int port = 0;
133 std::ifstream ifs(file.c_str());
137 std::vector<std::pair<std::string, int> > weights;
144 ifs.open(file.c_str());
149 std::vector<std::string> schemaNames;
150 loaded = schema.
getNames(schemaNames);
169 std::vector<std::string> keys;
172 for (
size_t i = 0;i<keys.size();++i)
175 if (found!=std::string::npos)
178 if (found!=std::string::npos)
180 weights.push_back(std::make_pair(keys[i].substr(found), 1));
190 catch(Poco::Exception& e)
195 catch(std::exception& e)
210 return searcher.
easyStart(matchMode, sortMode, rankingMode, rankExpression);
238 return searcher.
open();
243 return searcher.
close();
345 std::string resultData;
346 timeval tvStart, tvStop;
347 gettimeofday(&tvStart, 0);
348 bool needDefaultJson =
false;
352 if (inputJsonMessage.
isError())
355 if (inputJsonMessage.
getType() == SphinxInputJsonMessage::MessageType::mtSearch)
357 needDefaultJson =
true;
359 if (resultData.empty())
362 else if (inputJsonMessage.
getType() == SphinxInputJsonMessage::MessageType::mtIndex)
366 else if (inputJsonMessage.
getType() == SphinxInputJsonMessage::MessageType::mtManage)
374 catch(Poco::Exception& e)
380 catch(std::exception& e)
388 gettimeofday(&tvStop, 0);
393 outputMessage.
setData(resultData);
410 std::string resultData;
411 timeval tvStart, tvStop;
412 gettimeofday(&tvStart, 0);
413 bool needDefaultJson =
false;
416 if (inputJsonMessage.
getType() == SphinxInputJsonMessage::MessageType::mtSearch)
418 needDefaultJson =
true;
420 if (resultData.empty())
423 else if (inputJsonMessage.
getType() == SphinxInputJsonMessage::MessageType::mtIndex)
427 else if (inputJsonMessage.
getType() == SphinxInputJsonMessage::MessageType::mtManage)
434 catch(Poco::Exception& e)
440 catch(std::exception& e)
447 gettimeofday(&tvStop, 0);
452 outputMessage.
setData(resultData);
455 return outputMessage;
458 std::string SphinxFunctionalObject::makeDefaultJSON(
const std::string& logMsg)