mirror of
https://github.com/laurent22/joplin.git
synced 2025-02-13 19:42:36 +02:00
Chore: Fixed search engine result type
This commit is contained in:
parent
b7c85e1930
commit
6392a1e00f
@ -307,7 +307,7 @@ class Dialog extends React.PureComponent<Props, State> {
|
|||||||
} else { // Note TITLE or BODY
|
} else { // Note TITLE or BODY
|
||||||
listType = BaseModel.TYPE_NOTE;
|
listType = BaseModel.TYPE_NOTE;
|
||||||
searchQuery = gotoAnythingStyleQuery(this.state.query);
|
searchQuery = gotoAnythingStyleQuery(this.state.query);
|
||||||
results = await SearchEngine.instance().search(searchQuery);
|
results = (await SearchEngine.instance().search(searchQuery)) as any[];
|
||||||
|
|
||||||
resultsInBody = !!results.find((row: any) => row.fields.includes('body'));
|
resultsInBody = !!results.find((row: any) => row.fields.includes('body'));
|
||||||
|
|
||||||
|
@ -29,7 +29,8 @@ interface SearchOptions {
|
|||||||
appendWildCards?: boolean;
|
appendWildCards?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ProcessResultsRow {
|
export interface ProcessResultsRow {
|
||||||
|
id: string;
|
||||||
offsets: string;
|
offsets: string;
|
||||||
user_updated_time: number;
|
user_updated_time: number;
|
||||||
matchinfo: Buffer;
|
matchinfo: Buffer;
|
||||||
@ -612,7 +613,7 @@ export default class SearchEngine {
|
|||||||
return SearchEngine.SEARCH_TYPE_FTS;
|
return SearchEngine.SEARCH_TYPE_FTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async search(searchString: string, options: SearchOptions = null) {
|
public async search(searchString: string, options: SearchOptions = null): Promise<ProcessResultsRow[]> {
|
||||||
if (!searchString) return [];
|
if (!searchString) return [];
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
@ -627,7 +628,6 @@ export default class SearchEngine {
|
|||||||
if (searchType === SearchEngine.SEARCH_TYPE_BASIC) {
|
if (searchType === SearchEngine.SEARCH_TYPE_BASIC) {
|
||||||
searchString = this.normalizeText_(searchString);
|
searchString = this.normalizeText_(searchString);
|
||||||
const rows = await this.basicSearch(searchString);
|
const rows = await this.basicSearch(searchString);
|
||||||
|
|
||||||
this.processResults_(rows, parsedQuery, true);
|
this.processResults_(rows, parsedQuery, true);
|
||||||
return rows;
|
return rows;
|
||||||
} else {
|
} else {
|
||||||
@ -654,8 +654,8 @@ export default class SearchEngine {
|
|||||||
const useFts = searchType === SearchEngine.SEARCH_TYPE_FTS;
|
const useFts = searchType === SearchEngine.SEARCH_TYPE_FTS;
|
||||||
try {
|
try {
|
||||||
const { query, params } = queryBuilder(parsedQuery.allTerms, useFts);
|
const { query, params } = queryBuilder(parsedQuery.allTerms, useFts);
|
||||||
const rows = await this.db().selectAll(query, params);
|
const rows = (await this.db().selectAll(query, params)) as ProcessResultsRow[];
|
||||||
this.processResults_(rows as ProcessResultsRow[], parsedQuery, !useFts);
|
this.processResults_(rows, parsedQuery, !useFts);
|
||||||
return rows;
|
return rows;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger().warn(`Cannot execute MATCH query: ${searchString}: ${error.message}`);
|
this.logger().warn(`Cannot execute MATCH query: ${searchString}: ${error.message}`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user