Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Marian/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ export default class Marian {
}
const res = await fetch(url);
const toml = await res.text();

return parse(toml);
} catch (e) {
log.error(`Error while fetching taxonomy: ${JSON.stringify(e)}`);
Expand Down
30 changes: 17 additions & 13 deletions src/Query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,32 @@ function constructBuryOperators(parts: Part[]): CompoundPart[] {
//if given query matches a "part" result not in BURIED_PROPERTY(ex: Realm) docs, score remains unaffected
{
compound: {
must: [part],
mustNot: [
must: [
part,
{
text: {
query: BURIED_PROPERTIES,
path: 'searchProperty',
},
},
],
},
},
//if given query matches a "part" result in BURIED_PROPERTY(ex: Realm) docs, bury that result
{
compound: {
must: [
part,
// DOP-5772: Removed the part from the mustNot, and removed the second compound statement
// as that was interfering with the search results by surfacing pages we do not want.
mustNot: [
{
text: {
query: BURIED_PROPERTIES,
path: 'searchProperty',
},
},
],
},
},
//if given query matches a "part" result in BURIED_PROPERTY(ex: Realm) docs, bury that result
{
text: {
query: BURIED_PROPERTIES,
path: 'searchProperty',
score: { boost: { value: BURIED_FACTOR } },
},
}
Expand Down Expand Up @@ -121,15 +124,16 @@ export class Query {

// if we need to boost for matching slug on an exact rawQuery match
const boostedStrings = strippedMapping[this.rawQuery.trim()];
if (Array.isArray(boostedStrings) && typeof boostedStrings[0] === 'string') {

if (Array.isArray(boostedStrings)) {
parts.push(
...boostedStrings.map((boostedString, i) => ({
text: {
path: 'strippedSlug',
query: [boostedString],
// Boost each entry slightly higher than the next so that entry
// order is respected in results
score: { boost: { value: 100 + 10 * (boostedStrings.length - i) } },
// Use a constant score value to guarantee that we receive the order
// that we are expecting from the term-result-mappings object.
score: { constant: { value: 200 ** (boostedStrings.length - i) } },
},
}))
);
Expand Down
5 changes: 4 additions & 1 deletion src/Query/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ type PathObj = {
type Path = string | PathObj;

export type Score = {
boost: {
boost?: {
value: number;
};
constant?: {
value: number;
};
};
Expand Down
1 change: 1 addition & 0 deletions src/SearchPropertyMapping/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const setPropertyMapping = async function () {
const dbName = process.env['POOL_DB'] ?? 'pool_test';

const poolAtlasUri = verifyAndGetEnvVars();

const client = await MongoClient.connect(poolAtlasUri);
const db = client.db(dbName);
const collection = db.collection<Repo>(collectionName);
Expand Down
16 changes: 5 additions & 11 deletions src/data/term-result-mappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ const resultMapping: ResultMapping = {
'reference/sql-aggregation-comparison',
],
operator: ['reference/operator/query', 'reference/operator/update', 'reference/operator/aggregation-pipeline'],
exists: ['reference/operator/query/exists', 'atlas/atlas-search/exists', 'drivers/node/current/crud/query/query-document/'],
$exists: ['reference/operator/query/exists', 'atlas/atlas-search/exists', 'drivers/node/current/crud/query/query-document/'],
exist: ['reference/operator/query/exists', 'atlas/atlas-search/exists', 'drivers/node/current/crud/query/query-document/'],
exists: ['reference/operator/query/exists', 'atlas-search/exists', 'drivers/node/current/crud/query/query-document/'],
$exists: ['reference/operator/query/exists', 'atlas-search/exists', 'crud/query/query-document/'],
exist: ['reference/operator/query/exists', 'atlas-search/exists', 'drivers/node/current/crud/query/query-document/'],
mongoclient: [
'drivers/kotlin/coroutine/current/fundamentals/connection/mongoclientsettings',
'drivers/java/sync/current/connection/mongoclient',
Expand Down Expand Up @@ -151,10 +151,7 @@ const resultMapping: ResultMapping = {
$regex: ['reference/operator/query/regex', 'atlas/atlas-search/regex', 'reference/operator/aggregation/regexMatch'],
$eq: ['reference/operator/query/eq', 'reference/operator/aggregation/eq', 'reference/operator/query/elemMatch'],
$size: ['reference/operator/query/size', 'reference/operator/aggregation/size', 'tutorial/query-arrays'],
$sort: [
'reference/operator/update/sort',
'reference/operator/aggregation/sort',
],
$sort: ['reference/operator/update/sort', 'reference/operator/aggregation/sort'],
$inc: [
'reference/operator/update/inc',
'reference/method/db.collection.updateMany',
Expand All @@ -178,10 +175,7 @@ const resultMapping: ResultMapping = {
'tutorial/update-documents-with-aggregation-pipeline',
'reference/operator/aggregation/sum',
],
$first: [
'reference/operator/aggregation/first',
'reference/operator/aggregation/firstN',
],
$first: ['reference/operator/aggregation/first', 'reference/operator/aggregation/firstN'],
$count: ['reference/operator/aggregation/count', 'reference/command/count', 'atlas/atlas-search/counting'],
indexes: ['indexes'],
$addFields: [
Expand Down
Loading