From f36be06355bff894ff1bb19ba6493a77c2732778 Mon Sep 17 00:00:00 2001 From: Andy Rickert Date: Thu, 4 Jun 2020 20:16:27 -0400 Subject: highlights --- src/client/views/search/SearchBox.tsx | 54 ++++++++++++++++++++-------------- src/client/views/search/SearchItem.tsx | 9 +++--- 2 files changed, 36 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index 0ae9b4bb3..c38c4c1b9 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -382,21 +382,6 @@ export class SearchBox extends ViewBoxBaseComponent { - - }); - while (this.buckets!.length { while (this._results.length <= this._endIndex && (this._numTotalResults === -1 || this._maxSearchIndex < this._numTotalResults)) { - this._curRequest = SearchUtil.Search(query, true, {fq: this.filterQuery, start: this._maxSearchIndex, rows: this.NumResults, hl: true, "hl.fl": "*", "facet":"on", "facet.field":"_height" }).then(action(async (res: SearchUtil.DocSearchResult) => { + this._curRequest = SearchUtil.Search(query, true, {fq: this.filterQuery, start: this._maxSearchIndex, rows: this.NumResults, hl: true, "hl.fl": "*",}).then(action(async (res: SearchUtil.DocSearchResult) => { // happens at the beginning if (res.numFound !== this._numTotalResults && this._numTotalResults === -1) { this._numTotalResults = res.numFound; @@ -604,7 +594,6 @@ export class SearchBox extends ViewBoxBaseComponent) => { if (!this._resultsRef.current) return; - this.makebuckets(); const scrollY = e ? e.currentTarget.scrollTop : this._resultsRef.current ? this._resultsRef.current.scrollTop : 0; const itemHght = 53; @@ -666,7 +655,8 @@ export class SearchBox extends ViewBoxBaseComponent(result[2]); + let lines = new List(result[2]); + result[0].lines=lines result[0].highlighting=highlights.join(", "); this._visibleDocuments[i] = result[0]; @@ -708,6 +698,7 @@ export class SearchBox extends ViewBoxBaseComponent3){ this.makenewbuckets(); for (let i = 0; i < this._numTotalResults; i++) { console.log(this._isSearch[i],this._isSorted[i]); @@ -729,10 +720,31 @@ export class SearchBox extends ViewBoxBaseComponent= this._numTotalResults) { this._visibleElements.length = this._results.length; @@ -790,8 +802,6 @@ export class SearchBox extends ViewBoxBaseComponent
@@ -384,9 +384,8 @@ export class SearchItem extends ViewBoxBaseComponent
{StrCast(this.targetDoc.title)}
-
{StrCast(this.targetDoc.highlighting).length ? "Matched fields:" + StrCast(this.targetDoc.highlighting) : //this.props.lines.length ? this.props.lines[0] : - ""}
- {/* {this.props.lines!.filter((m, i) => i).map((l, i) =>
`${l}`
)} */} +
{StrCast(this.targetDoc.highlighting).length ? "Matched fields:" + StrCast(this.targetDoc.highlighting) : Cast(this.targetDoc.lines, listSpec("string"))!.length ? Cast(this.targetDoc.lines, listSpec("string"))![0] : ""}
+ {Cast(this.targetDoc.lines, listSpec("string"))!.filter((m, i) => i).map((l, i) =>
{l}
)}
-- cgit v1.2.3-70-g09d2