Skip to content

Commit

Permalink
Build version 0.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
weixsong committed Sep 7, 2016
1 parent 6ebe311 commit 065b743
Show file tree
Hide file tree
Showing 17 changed files with 86 additions and 53 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.mdown
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#

## 0.9.2

* some update
* clean the document about other language support

## 0.9.1

* merged pull request from [Dave Allie](https://github.com/weixsong/elasticlunr.js/pull/24), allow boost equal 0, and do not search field with 0 boost.
Expand Down
22 changes: 5 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,23 +147,6 @@ index.setRef('id');
index.saveDocument(false);
```

Default supported language of elasticlunr.js is English, if you want to use elasticlunr.js to index other language documents, then you need to use elasticlunr.js combined with [lunr-languages](https://github.com/MihaiValentin/lunr-languages).
Assume you're using lunr-language in Node.js envrionment, you could import lunr-language as followings:

```javascript
var elasticlunr = require('elasticlunr');
require('./lunr.stemmer.support.js')(elasticlunr);
require('./lunr.de.js')(elasticlunr);

var index = elasticlunr(function () {
// use the language (de)
this.use(lunr.de);
// then, the normal elasticlunr index initialization
this.addField('title')
this.addField('body')
});
```
For more details, please go to [lunr-languages](https://github.com/MihaiValentin/lunr-languages).

## 2. Add document to index

Expand Down Expand Up @@ -383,6 +366,11 @@ index.addDoc(doc2);
index.search("Oracle database profit");
```

# Other Languages?
Sorry for the original version documents that I think elasticlunr.js will support [lunr-languages](https://github.com/MihaiValentin/lunr-languages) seamlessly, I was wrong. [lunr-languages](https://github.com/MihaiValentin/lunr-languages) is developed based on [lunr.js](https://github.com/olivernn/lunr.js) and not work in **Elasticlunr.js**.
I will refactor the code and support all the languages that available in [lunr-languages](https://github.com/MihaiValentin/lunr-languages).


# Contributing

See the [`CONTRIBUTING.mdown` file](CONTRIBUTING.mdown).
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.0
0.9.2
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "elasticlunr.js",
"version": "0.9.0",
"version": "0.9.2",
"main": "elasticlunr.js",
"ignore": [
"tests/",
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "elasticlunr",
"repo": "weixsong/elasticlunr.js",
"version": "0.9.0",
"version": "0.9.2",
"description": "Lightweight full-text search engine in Javascript for browser search and offline search.",
"license": "MIT",
"main": "elasticlunr.js",
Expand Down
4 changes: 2 additions & 2 deletions docs/configuration.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ <h5 class="subheader"></h5>
<li>boolean model chosing, user could choose which boolean model to use for each field.</li>
<li>token expandation, user could set token expand to True to improve Recall. Default is False.</li>
</ol>
<p>Query time boosting must be configured by field category, &quot;boolean&quot; model could be configured<br />by both field category or globally as the following example. Field configuration for &quot;boolean&quot;<br />will overwrite global configuration.<br />Token expand could be configured both by field category or golbally. Local field configuration will<br />overwrite global configuration.</p><p>configuration example:<br />{<br /> fields:{<br /> title: {boost: 2},<br /> body: {boost: 1}<br /> },<br /> bool: &quot;OR&quot;<br />}</p><p>&quot;bool&quot; field configuation overwrite global configuation example:<br />{<br /> fields:{<br /> title: {boost: 2, bool: &quot;AND&quot;},<br /> body: {boost: 1}<br /> },<br /> bool: &quot;OR&quot;<br />}</p><p>&quot;expand&quot; example:<br />{<br /> fields:{<br /> title: {boost: 2, bool: &quot;AND&quot;},<br /> body: {boost: 1}<br /> },<br /> bool: &quot;OR&quot;,<br /> expand: true<br />}</p><p>&quot;expand&quot; example for field category:<br />{<br /> fields:{<br /> title: {boost: 2, bool: &quot;AND&quot;, expand: true},<br /> body: {boost: 1}<br /> },<br /> bool: &quot;OR&quot;<br />}</p><p>then, user could search with configuration to do query-time boosting.<br />idx.search(&#39;oracle database&#39;, {fields: {title: {boost: 2}, body: {boost: 1}}});</p> </div>
<p>Query time boosting must be configured by field category, &quot;boolean&quot; model could be configured<br />by both field category or globally as the following example. Field configuration for &quot;boolean&quot;<br />will overwrite global configuration.<br />Token expand could be configured both by field category or golbally. Local field configuration will<br />overwrite global configuration.</p><p>configuration example:<br />{<br /> fields:{<br /> title: {boost: 2},<br /> body: {boost: 1}<br /> },<br /> bool: &quot;OR&quot;<br />}</p><p>&quot;bool&quot; field configuation overwrite global configuation example:<br />{<br /> fields:{<br /> title: {boost: 2, bool: &quot;AND&quot;},<br /> body: {boost: 1}<br /> },<br /> bool: &quot;OR&quot;<br />}</p><p>&quot;expand&quot; example:<br />{<br /> fields:{<br /> title: {boost: 2, bool: &quot;AND&quot;},<br /> body: {boost: 1}<br /> },<br /> bool: &quot;OR&quot;,<br /> expand: true<br />}</p><p>&quot;expand&quot; example for field category:<br />{<br /> fields:{<br /> title: {boost: 2, bool: &quot;AND&quot;, expand: true},<br /> body: {boost: 1}<br /> },<br /> bool: &quot;OR&quot;<br />}</p><p>setting the boost to 0 ignores the field (this will only search the title):<br />{<br /> fields:{<br /> title: {boost: 1},<br /> body: {boost: 0}<br /> }<br />}</p><p>then, user could search with configuration to do query-time boosting.<br />idx.search(&#39;oracle database&#39;, {fields: {title: {boost: 2}, body: {boost: 1}}});</p> </div>
<pre><code class="language-javascript">elasticlunr.Configuration = function (config, fields) {
var config = config || '';

Expand Down Expand Up @@ -241,7 +241,7 @@ <h5 class="subheader"></h5>
}

this.config[field] = {
boost: field_config.boost || 1,
boost: (field_config.boost || field_config.boost === 0) ? field_config.boost : 1,
bool: field_config.bool || global_bool,
expand: field_expand
};
Expand Down
17 changes: 3 additions & 14 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,7 @@ <h2>Example</h2>
index.setRef(&#39;id&#39;);
index.saveDocument(false);
</code></pre>
<p>Default supported language of elasticlunr.js is English, if you want to use elasticlunr.js to index other language documents, then you need to use elasticlunr.js combined with <a href="https://github.com/weixsong/lunr-languages">lunr-languages</a>.<br />Assume you&#39;re using lunr-language in Node.js envrionment, you could import lunr-language as followings:</p><pre><code class="lang-javascript">var elasticlunr = require(&#39;elasticlunr&#39;);
require(&#39;./lunr.stemmer.support.js&#39;)(elasticlunr);
require(&#39;./lunr.de.js&#39;)(elasticlunr);

var index = elasticlunr(function () {
// use the language (de)
this.use(lunr.de);
// then, the normal elasticlunr index initialization
this.addField(&#39;title&#39;)
this.addField(&#39;body&#39;)
});
</code></pre>
<p>For more details, please go to <a href="https://github.com/weixsong/lunr-languages">lunr-languages</a>.</p><h2>2. Add document to index</h2>
<h2>2. Add document to index</h2>
<p>Add document to index is very simple, just prepare you document in JSON format, then add it to index.</p><pre><code class="lang-javascript">var doc1 = {
&quot;id&quot;: 1,
&quot;title&quot;: &quot;Oracle released its latest database Oracle 12g&quot;,
Expand Down Expand Up @@ -324,7 +312,8 @@ <h2>7. Use elasticlunr in Node.js</h2>

index.search(&quot;Oracle database profit&quot;);
</code></pre>
<h1>Contributing</h1>
<h1>Other Languages?</h1>
<p>Sorry for the original version documents that I think elasticlunr.js will support <a href="https://github.com/MihaiValentin/lunr-languages">lunr-languages</a> seamlessly, I was wrong. <a href="https://github.com/MihaiValentin/lunr-languages">lunr-languages</a> is developed based on <a href="https://github.com/olivernn/lunr.js">lunr.js</a> and not work in <strong>Elasticlunr.js</strong>.<br />I will refactor the code and support all the languages that available in <a href="https://github.com/MihaiValentin/lunr-languages">lunr-languages</a>.</p><h1>Contributing</h1>
<p>See the <a href="CONTRIBUTING.mdown"><code>CONTRIBUTING.mdown</code> file</a>.</p></section>
</div>
</div>
Expand Down
6 changes: 6 additions & 0 deletions docs/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -673,9 +673,15 @@ <h5 class="subheader"></h5>
<pre><code class="language-javascript">elasticlunr.Index.prototype.fieldSearch = function (queryTokens, fieldName, config) {
var booleanType = config[fieldName].bool;
var expand = config[fieldName].expand;
var boost = config[fieldName].boost;
var scores = null;
var docTokens = {};

// Do nothing if the boost is 0
if (boost === 0) {
return;
}

queryTokens.forEach(function (token) {
var tokens = [token];
if (expand == true) {
Expand Down
20 changes: 17 additions & 3 deletions elasticlunr.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* elasticlunr - http://weixsong.github.io
* Lightweight full-text search engine in Javascript for browser search and offline search. - 0.9.0
* Lightweight full-text search engine in Javascript for browser search and offline search. - 0.9.2
*
* Copyright (C) 2016 Oliver Nightingale
* Copyright (C) 2016 Wei Song
Expand Down Expand Up @@ -83,7 +83,7 @@ var elasticlunr = function (config) {
return idx;
};

elasticlunr.version = "0.9.0";
elasticlunr.version = "0.9.2";
/*!
* elasticlunr.utils
* Copyright (C) 2016 Oliver Nightingale
Expand Down Expand Up @@ -929,9 +929,15 @@ elasticlunr.Index.prototype.search = function (query, userConfig) {
elasticlunr.Index.prototype.fieldSearch = function (queryTokens, fieldName, config) {
var booleanType = config[fieldName].bool;
var expand = config[fieldName].expand;
var boost = config[fieldName].boost;
var scores = null;
var docTokens = {};

// Do nothing if the boost is 0
if (boost === 0) {
return;
}

queryTokens.forEach(function (token) {
var tokens = [token];
if (expand == true) {
Expand Down Expand Up @@ -2069,6 +2075,14 @@ elasticlunr.InvertedIndex.prototype.toJSON = function () {
* bool: "OR"
* }
*
* setting the boost to 0 ignores the field (this will only search the title):
* {
* fields:{
* title: {boost: 1},
* body: {boost: 0}
* }
* }
*
* then, user could search with configuration to do query-time boosting.
* idx.search('oracle database', {fields: {title: {boost: 2}, body: {boost: 1}}});
*
Expand Down Expand Up @@ -2143,7 +2157,7 @@ elasticlunr.Configuration.prototype.buildUserConfig = function (config, fields)
}

this.config[field] = {
boost: field_config.boost || 1,
boost: (field_config.boost || field_config.boost === 0) ? field_config.boost : 1,
bool: field_config.bool || global_bool,
expand: field_expand
};
Expand Down
4 changes: 2 additions & 2 deletions elasticlunr.min.js

Large diffs are not rendered by default.

20 changes: 17 additions & 3 deletions example/elasticlunr.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* elasticlunr - http://weixsong.github.io
* Lightweight full-text search engine in Javascript for browser search and offline search. - 0.9.0
* Lightweight full-text search engine in Javascript for browser search and offline search. - 0.9.2
*
* Copyright (C) 2016 Oliver Nightingale
* Copyright (C) 2016 Wei Song
Expand Down Expand Up @@ -83,7 +83,7 @@ var elasticlunr = function (config) {
return idx;
};

elasticlunr.version = "0.9.0";
elasticlunr.version = "0.9.2";
/*!
* elasticlunr.utils
* Copyright (C) 2016 Oliver Nightingale
Expand Down Expand Up @@ -929,9 +929,15 @@ elasticlunr.Index.prototype.search = function (query, userConfig) {
elasticlunr.Index.prototype.fieldSearch = function (queryTokens, fieldName, config) {
var booleanType = config[fieldName].bool;
var expand = config[fieldName].expand;
var boost = config[fieldName].boost;
var scores = null;
var docTokens = {};

// Do nothing if the boost is 0
if (boost === 0) {
return;
}

queryTokens.forEach(function (token) {
var tokens = [token];
if (expand == true) {
Expand Down Expand Up @@ -2069,6 +2075,14 @@ elasticlunr.InvertedIndex.prototype.toJSON = function () {
* bool: "OR"
* }
*
* setting the boost to 0 ignores the field (this will only search the title):
* {
* fields:{
* title: {boost: 1},
* body: {boost: 0}
* }
* }
*
* then, user could search with configuration to do query-time boosting.
* idx.search('oracle database', {fields: {title: {boost: 2}, body: {boost: 1}}});
*
Expand Down Expand Up @@ -2143,7 +2157,7 @@ elasticlunr.Configuration.prototype.buildUserConfig = function (config, fields)
}

this.config[field] = {
boost: field_config.boost || 1,
boost: (field_config.boost || field_config.boost === 0) ? field_config.boost : 1,
bool: field_config.bool || global_bool,
expand: field_expand
};
Expand Down
4 changes: 2 additions & 2 deletions example/elasticlunr.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/example_index.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions notes
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
** TODO:

**support different languages, refactor the desgin, write base class for tokenizer, stemmer, etc. P1**

1. Add support for scoring model choice, such as sum up the field score or just use the max field score.
2. Code review, make it more efficient.
3. search configuration format verification, check that user's configuration is correct and legal.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "elasticlunr",
"description": "Lightweight full-text search engine in Javascript for browser search and offline search.",
"version": "0.9.0",
"version": "0.9.2",
"author": "Wei Song",
"keywords": ["search", "text retrieval", "offline search", "full text search"],
"homepage": "http://weixsong.github.io",
Expand Down
20 changes: 17 additions & 3 deletions release/elasticlunr.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* elasticlunr - http://weixsong.github.io
* Lightweight full-text search engine in Javascript for browser search and offline search. - 0.9.0
* Lightweight full-text search engine in Javascript for browser search and offline search. - 0.9.2
*
* Copyright (C) 2016 Oliver Nightingale
* Copyright (C) 2016 Wei Song
Expand Down Expand Up @@ -83,7 +83,7 @@ var elasticlunr = function (config) {
return idx;
};

elasticlunr.version = "0.9.0";
elasticlunr.version = "0.9.2";
/*!
* elasticlunr.utils
* Copyright (C) 2016 Oliver Nightingale
Expand Down Expand Up @@ -929,9 +929,15 @@ elasticlunr.Index.prototype.search = function (query, userConfig) {
elasticlunr.Index.prototype.fieldSearch = function (queryTokens, fieldName, config) {
var booleanType = config[fieldName].bool;
var expand = config[fieldName].expand;
var boost = config[fieldName].boost;
var scores = null;
var docTokens = {};

// Do nothing if the boost is 0
if (boost === 0) {
return;
}

queryTokens.forEach(function (token) {
var tokens = [token];
if (expand == true) {
Expand Down Expand Up @@ -2069,6 +2075,14 @@ elasticlunr.InvertedIndex.prototype.toJSON = function () {
* bool: "OR"
* }
*
* setting the boost to 0 ignores the field (this will only search the title):
* {
* fields:{
* title: {boost: 1},
* body: {boost: 0}
* }
* }
*
* then, user could search with configuration to do query-time boosting.
* idx.search('oracle database', {fields: {title: {boost: 2}, body: {boost: 1}}});
*
Expand Down Expand Up @@ -2143,7 +2157,7 @@ elasticlunr.Configuration.prototype.buildUserConfig = function (config, fields)
}

this.config[field] = {
boost: field_config.boost || 1,
boost: (field_config.boost || field_config.boost === 0) ? field_config.boost : 1,
bool: field_config.bool || global_bool,
expand: field_expand
};
Expand Down
4 changes: 2 additions & 2 deletions release/elasticlunr.min.js

Large diffs are not rendered by default.

0 comments on commit 065b743

Please sign in to comment.