9 #include "searchheader.h" |
9 #include "searchheader.h" |
10 #include "clucene/document/document.h" |
10 #include "clucene/document/document.h" |
11 #include "clucene/index/indexreader.h" |
11 #include "clucene/index/indexreader.h" |
12 #include "filter.h" |
12 #include "filter.h" |
13 #include "clucene/search/searchheader.h" |
13 #include "clucene/search/searchheader.h" |
|
14 //#ifdef USE_HIGHLIGHTER |
|
15 //#include "CLucene/highlighter/QueryTermExtractor.h" |
|
16 //#include "CLucene/highlighter/QueryScorer.h" |
|
17 //#include "CLucene/highlighter/Highlighter.h" |
|
18 //#include "CLucene/highlighter/SimpleHTMLFormatter.h" |
|
19 //#include "CLucene/analysis/standard/StandardAnalyzer.h" |
|
20 //#endif |
14 |
21 |
15 CL_NS_USE(document) |
22 CL_NS_USE(document) |
16 CL_NS_USE(util) |
23 CL_NS_USE(util) |
17 CL_NS_USE(index) |
24 CL_NS_USE(index) |
18 |
25 |
40 } |
47 } |
41 |
48 |
42 |
49 |
43 Hits::Hits(Searcher* s, Query* q, Filter* f, const Sort* _sort): |
50 Hits::Hits(Searcher* s, Query* q, Filter* f, const Sort* _sort): |
44 query(q), searcher(s), filter(f), sort(_sort) |
51 query(q), searcher(s), filter(f), sort(_sort) |
|
52 //#ifdef USE_HIGHLIGHTER |
|
53 // , hl_frag(20) |
|
54 //#endif |
45 { |
55 { |
46 //Func - Constructor |
56 //Func - Constructor |
47 //Pre - s contains a valid reference to a searcher s |
57 //Pre - s contains a valid reference to a searcher s |
48 // q contains a valid reference to a Query |
58 // q contains a valid reference to a Query |
49 // f is NULL or contains a pointer to a filter |
59 // f is NULL or contains a pointer to a filter |
81 } |
91 } |
82 |
92 |
83 if (hitDoc->doc == NULL){ |
93 if (hitDoc->doc == NULL){ |
84 hitDoc->doc = _CLNEW Document; |
94 hitDoc->doc = _CLNEW Document; |
85 searcher->doc(hitDoc->id, hitDoc->doc); // cache miss: read document |
95 searcher->doc(hitDoc->id, hitDoc->doc); // cache miss: read document |
|
96 //#ifdef USE_HIGHLIGHTER |
|
97 // CL_NS(document)::Document* document = hitDoc->doc; |
|
98 // |
|
99 // const TCHAR* text = document->get(LCPIX_EXCERPT_FIELD); |
|
100 // |
|
101 // if(text) |
|
102 // { |
|
103 // Query* rwquery = searcher->getrewritten(hitDoc->id, query); |
|
104 // |
|
105 // TCHAR * str = rwquery->toString(); |
|
106 // |
|
107 // CL_NS2(search,highlight)::QueryScorer hl_scorer(rwquery); |
|
108 // |
|
109 // CL_NS2(search,highlight)::Highlighter highlighter(&hl_formatter, &hl_scorer); |
|
110 // |
|
111 // highlighter.setTextFragmenter(&hl_frag); |
|
112 // |
|
113 // wstring hlText; |
|
114 // |
|
115 // StringReader strreader(text); |
|
116 // |
|
117 // lucene::analysis::TokenStream * tokenStream = hl_analyzer.tokenStream(LCPIX_EXCERPT_FIELD, &strreader); |
|
118 // |
|
119 // TCHAR* result = highlighter.getBestFragments(tokenStream, text, 2,L"..."); |
|
120 // |
|
121 // if (result != NULL) |
|
122 // { |
|
123 // hlText.append(result); |
|
124 // |
|
125 // document->removeField( LCPIX_EXCERPT_FIELD ); |
|
126 // |
|
127 // document->add(*_CLNEW Field(LCPIX_EXCERPT_FIELD, |
|
128 // hlText.c_str(), lucene::document::Field::STORE_YES | lucene::document::Field::INDEX_NO)); |
|
129 // } |
|
130 // } |
|
131 //#endif |
86 } |
132 } |
87 |
133 |
88 return *hitDoc->doc; |
134 return *hitDoc->doc; |
89 } |
135 } |
90 |
136 |