Skip to content

Commit

Permalink
refactor(full-text-search): make the id field optional undefined (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
Viatorus authored Dec 4, 2017
1 parent b338990 commit eb4fed5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function createLanguageTest(language: string, data: LanguageTestData) {
let fts = new FullTextSearch([{
name: "body",
tokenizer: data.tokenizer
}]);
}], "$loki");

// Add documents.
for (let i = 0; i < data.docs.length; i++) {
Expand Down
10 changes: 5 additions & 5 deletions packages/full-text-search/spec/generic/search/fuzzy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe("fuzzy query", () => {

it("Fuzzy query (1).", () => {
let docs = ["aaaaa", "aaaab", "aaabb", "aabbb", "abbbb", "bbbbb", "ddddd"];
let fts = new FullTextSearch([{name: "body"}]);
let fts = new FullTextSearch([{name: "body"}], "$loki");
for (let i = 0; i < docs.length; i++) {
fts.addDocument({
$loki: i,
Expand Down Expand Up @@ -141,7 +141,7 @@ describe("fuzzy query", () => {
it("Fuzzy query (2).", () => {
let docs = ["lange", "lueth", "pirsing", "riegel", "trzecziak", "walker", "wbr", "we", "web", "webe", "weber",
"webere", "webree", "weberei", "wbre", "wittkopf", "wojnarowski", "wricke"];
let fts = new FullTextSearch([{name: "body"}]);
let fts = new FullTextSearch([{name: "body"}], "$loki");
for (let i = 0; i < docs.length; i++) {
fts.addDocument({
$loki: i,
Expand All @@ -164,7 +164,7 @@ describe("fuzzy query", () => {
return tokens.split(" ");
});

let fts = new FullTextSearch([{name: "body", tokenizer: tkz}]);
let fts = new FullTextSearch([{name: "body", tokenizer: tkz}], "$loki");
for (let i = 0; i < docs.length; i++) {
fts.addDocument({
$loki: i,
Expand All @@ -178,7 +178,7 @@ describe("fuzzy query", () => {
it("Fuzzy query extended.", () => {
let docs = ["walker", "wbr", "we", "web", "webe", "weber", "webere", "webree", "weberei", "wbes", "wbert", "wbb",
"xeb", "wrr", "wrr"];
let fts = new FullTextSearch([{name: "body"}]);
let fts = new FullTextSearch([{name: "body"}], "$loki");
for (let i = 0; i < docs.length; i++) {
fts.addDocument({
$loki: i,
Expand All @@ -195,7 +195,7 @@ describe("fuzzy query", () => {

it("Fuzzy query extended.", () => {
let docs = ["abca", "abcd", "abcde"];
let fts = new FullTextSearch([{name: "body"}]);
let fts = new FullTextSearch([{name: "body"}], "$loki");
for (let i = 0; i < docs.length; i++) {
fts.addDocument({
$loki: i,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("wildcard query", () => {

it("Tests Wildcard queries with an asterisk.", () => {
let docs = ["metal", "metals", "mXtals", "mXtXls"];
let fts = new FullTextSearch([{name: "body"}]);
let fts = new FullTextSearch([{name: "body"}], "$loki");
for (let i = 0; i < docs.length; i++) {
fts.addDocument({
$loki: i,
Expand Down Expand Up @@ -56,7 +56,7 @@ describe("wildcard query", () => {

it("Tests Wildcard queries with a question mark.", () => {
let docs = ["metal", "metals", "mXtals", "mXtXls"];
let fts = new FullTextSearch([{name: "body"}]);
let fts = new FullTextSearch([{name: "body"}], "$loki");
for (let i = 0; i < docs.length; i++) {
fts.addDocument({
$loki: i,
Expand Down Expand Up @@ -85,7 +85,7 @@ describe("wildcard query", () => {
// Don't split the text.
tkz.setSplitter("nosplit", (text) => [text]);

let fts = new FullTextSearch([{name: "body", tokenizer: tkz}]);
let fts = new FullTextSearch([{name: "body", tokenizer: tkz}], "$loki");
for (let i = 0; i < docs.length; i++) {
fts.addDocument({
$loki: i,
Expand Down
2 changes: 1 addition & 1 deletion packages/full-text-search/spec/node/elasticsearch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ describe("Compare scoring against elasticsearch", () => {
let fts = new FullTextSearch([{
name: FIELD_NAME_1,
tokenizer: tkz
}]);
}], "$loki");

// Add documents.
for (let i = 0; i < DATA.length; i++) {
Expand Down
4 changes: 2 additions & 2 deletions packages/full-text-search/src/full_text_search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export class FullTextSearch {
* @param {boolean=true} fields.optimizeChanges - flag to indicate if deleting/updating a document should be optimized
* (requires more memory but performs better)
* @param {Tokenizer=Tokenizer} fields.tokenizer - the tokenizer of the field
* @param {string=$loki} id - the property name of the document index
* @param {string} [id] - the property name of the document index
*/
constructor(fields: FullTextSearch.FieldOptions[] = [], id = "$loki") {
constructor(fields: FullTextSearch.FieldOptions[] = [], id?: string) {
// Create inverted indices for each field.
for (let i = 0; i < fields.length; i++) {
let field = fields[i];
Expand Down

0 comments on commit eb4fed5

Please sign in to comment.