fix(kb.gbapp): Simple search prioritized correctly.
This commit is contained in:
parent
7046d63457
commit
8136e34f1e
2 changed files with 17 additions and 27 deletions
|
@ -165,7 +165,6 @@ export class AskDialog extends IGBDialog {
|
||||||
return step.endDialog();
|
return step.endDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const locale = step.context.activity.locale;
|
const locale = step.context.activity.locale;
|
||||||
|
|
||||||
// Stops any content on projector.
|
// Stops any content on projector.
|
||||||
|
|
|
@ -190,7 +190,7 @@ export class KBService implements IGBKBService {
|
||||||
const service = new CSService();
|
const service = new CSService();
|
||||||
let question = await service.getQuestionFromAlternateText(instanceId, text);
|
let question = await service.getQuestionFromAlternateText(instanceId, text);
|
||||||
|
|
||||||
if (question !== null) {
|
if (!question) {
|
||||||
question = await GuaribasQuestion.findOne({
|
question = await GuaribasQuestion.findOne({
|
||||||
where: {
|
where: {
|
||||||
instanceId: instanceId,
|
instanceId: instanceId,
|
||||||
|
@ -223,6 +223,15 @@ export class KBService implements IGBKBService {
|
||||||
searchScore: number,
|
searchScore: number,
|
||||||
subjects: GuaribasSubject[]
|
subjects: GuaribasSubject[]
|
||||||
): Promise<KBServiceSearchResults> {
|
): Promise<KBServiceSearchResults> {
|
||||||
|
|
||||||
|
// Try simple search first.
|
||||||
|
|
||||||
|
const data = await this.getAnswerByText(instance.instanceId, query);
|
||||||
|
if (data) {
|
||||||
|
GBLog.info(`Simple SEARCH called.`);
|
||||||
|
return { answer: data.answer, questionId: data.question.questionId };
|
||||||
|
}
|
||||||
|
|
||||||
// Builds search query.
|
// Builds search query.
|
||||||
|
|
||||||
query = query.toLowerCase();
|
query = query.toLowerCase();
|
||||||
|
@ -240,9 +249,9 @@ export class KBService implements IGBKBService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let notSearched = true;
|
|
||||||
|
|
||||||
// tslint:disable:no-unsafe-any
|
// No direct match found, so Search is used.
|
||||||
|
|
||||||
if (instance.searchKey !== null && GBConfigService.get('STORAGE_DIALECT') === 'mssql') {
|
if (instance.searchKey !== null && GBConfigService.get('STORAGE_DIALECT') === 'mssql') {
|
||||||
const client = new SearchService(instance.searchHost.split('.')[0], instance.searchKey);
|
const client = new SearchService(instance.searchHost.split('.')[0], instance.searchKey);
|
||||||
const results = await client.indexes
|
const results = await client.indexes
|
||||||
|
@ -267,7 +276,7 @@ export class KBService implements IGBKBService {
|
||||||
GBLog.info(
|
GBLog.info(
|
||||||
`SEARCH WILL BE USED with score: ${returnedScore} > required (searchScore): ${searchScore}`
|
`SEARCH WILL BE USED with score: ${returnedScore} > required (searchScore): ${searchScore}`
|
||||||
);
|
);
|
||||||
notSearched = false;
|
|
||||||
|
|
||||||
return { answer: value, questionId: values[0].questionId };
|
return { answer: value, questionId: values[0].questionId };
|
||||||
} else {
|
} else {
|
||||||
|
@ -294,24 +303,6 @@ export class KBService implements IGBKBService {
|
||||||
return { answer: undefined, questionId: 0 };
|
return { answer: undefined, questionId: 0 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DISABLED: Searches via Database "WHERE" command.
|
|
||||||
|
|
||||||
// if (notSearched) {
|
|
||||||
// const data = await this.getAnswerByText(instance.instanceId, query);
|
|
||||||
// if (data) {
|
|
||||||
// GBLog.info(
|
|
||||||
// `SEARCH called.`
|
|
||||||
// );
|
|
||||||
// return { answer: data.answer, questionId: data.question.questionId };
|
|
||||||
// } else {
|
|
||||||
// GBLog.info(`SEARCH NOT called getAnswerByText not found answers in database.`);
|
|
||||||
// return { answer: undefined, questionId: 0 };
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// TODO: Add more sources....
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getSubjectItems(instanceId: number, parentId: number): Promise<GuaribasSubject[]> {
|
public async getSubjectItems(instanceId: number, parentId: number): Promise<GuaribasSubject[]> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue