Comments (11)
Supporting both formats is possible. The doc configuration needs a way to keep JSON standard compatibility.
from flexsearch.
@mahnunchik Thanks for the report. Could you provide me the used configuration or a short example please?
from flexsearch.
Hi @ts-thomas
import FlexSearch from 'flexsearch';
import waypoints from './data/waypoints';
const index = new FlexSearch({
doc: {
id: "code",
field: {
code: {
split: /\s+/,
tokenize: "strict",
},
title: {
split: /[\s()-]+/,
tokenize: "forward",
},
},
},
});
//console.time('index');
index.add(waypoints);
//console.timeEnd('index');
export default index;
Data: https://gist.github.com/mahnunchik/6920a1039a3da4ef22177521a800642d
from flexsearch.
@mahnunchik Sorry for the late answer. The issue here was the split-field needs a string value (to keep json compatibility):
const index = new FlexSearch({
doc: {
id: "code",
field: {
code: {
split: "/\s+/",
tokenize: "strict",
},
title: {
split: "/[\s()-]+/",
tokenize: "forward",
},
},
},
});
from flexsearch.
@ts-thomas it would be more predictable to have usual regexp in normal js configuration, not a string of js regexp. Or support both formats.
from flexsearch.
Hi @ts-thomas
It seems "/\s+/"
from your comment not works as expected in 0.6.22
.
from flexsearch.
Hi @ts-thomas
it doesn't work for me as well. the content.split(this.split) not works as this.split is just a string and not regex.
if i use regex in the field definition the clone_object is not working correctly:
clone_object({a:/a/}) = {a:{}}
from flexsearch.
patch to clone_object:
function clone_object(obj) {
const clone = create_object();
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
const value = obj[key];
if (is_array(value)) {
clone[key] = value.slice(0);
} else if (value instanceof RegExp) {
clone[key] = value;
} else if (is_object(value)) {
clone[key] = clone_object(value);
} else {
clone[key] = value;
}
}
}
return clone;
}
from flexsearch.
@wamir79 thanks for providing a fix.
from flexsearch.
Should this issue be closed?
from flexsearch.
Please change over to the version >= 0.7.x which solves that issue, thanks a lot.
from flexsearch.
Related Issues (20)
- RangeError: Invalid string length HOT 2
- How to import Document in nodejs with ESNext modules (typescript)?
- Invalid regular expression
- Suggestion and tokenize "forward"
- Webpack cannot resolve flexsearch HOT 1
- `IndexOptions` TS interface is missing some options HOT 1
- Current NPM package is stale HOT 2
- Cloning of flexsearch objects
- new Document causes `.default is not a constructor` error HOT 1
- Benchmark link is broken HOT 1
- Setting a string as "encode" doesn't work (confusing document?)
- How to return context (+ or - few lines) around the hits of given search text
- Enriched document search showing duplicate results
- I have a question about how the results are sorted
- Do not force string in Index#add() when custom encoder
- "Document Indexes" link in readme is broken
- Typo in cdn link
- TypeScript doesn't allow omitting id from the document descriptor while the README says it is allowed
- document search option "pluck" is rejected by TypeScript
- Some documents may appear multiple times in the search result
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flexsearch.