Novelty Polygonal Mathematics

    @ntix/indexing
    TypeScript icon, indicating that this package has built-in type declarations

    2.1.0 • Public • Published

    @ntix/indexing

    A small text indexer

    CI Known Vulnerabilities npm version

    Documentation

      import { IndexServiceBuilder } from './IndexServiceBuilder';
      import { indexGetWords, indexExact } from './builders/index';
    
      interface IPerson{
        id: string;
        name: string;
      }
    
      const items = [
        { id: '0-0', name: 'Aa Bb' },
        { id: '1-1', name: "Ab C-c's" },
        { id: '2-2', name: 'Bb Aa' },
        { id: '3-3', name: 'Cc Aa DD' },
        { id: '4-4', name: 'Cc Ca "DD"' },
        { id: '5-5', name: 'ABC' },
      ];
    
      const builder = IndexServiceBuilder.create<IPerson>()
          .add((item) => indexGetWords(item.name))
          .add((item) => indexExact(item.id));
    
      const index = builder
          .build(items);
      });
    
      const results = index.search('AB');
    
      > results 
      > { item: { id: '5-5', name: 'ABC' }, rank: 8.5 }

    See tests for more examples of usage

    Keywords

    Install

    npm i @ntix/indexing

    DownloadsWeekly Downloads

    4

    Version

    2.1.0

    License

    ISC

    Unpacked Size

    15.9 kB

    Total Files

    38

    Last publish

    Collaborators

    • antix