Link to home
Start Free TrialLog in
Avatar of Software Programmer
Software Programmer

asked on

Type-ahead search - Portable - Full Text

Type-ahead search like google

Does any open source software has this feature to index huge document and search as type-ahead like google for a text?
Avatar of Duncan Roe
Duncan Roe
Flag of Australia image

Are you referring to what Microsoft calls intellisense? LibreOffice has it, at least when typing in cell contents a spreadsheet.
Avatar of Software Programmer
Software Programmer

ASKER

No, like Type-ahead search like google
There are projects like https://twitter.github.io/typeahead.js/ and per the example http://twitter.github.io/typeahead.js/examples/
<div id="the-basics">
  <input class="typeahead" type="text" placeholder="States of USA">
</div>

Open in new window

var substringMatcher = function(strs) {
  return function findMatches(q, cb) {
    var matches, substringRegex;

    // an array that will be populated with substring matches
    matches = [];

    // regex used to determine if a string contains the substring `q`
    substrRegex = new RegExp(q, 'i');

    // iterate through the pool of strings and for any string that
    // contains the substring `q`, add it to the `matches` array
    $.each(strs, function(i, str) {
      if (substrRegex.test(str)) {
        matches.push(str);
      }
    });

    cb(matches);
  };
};

var states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California',
  'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii',
  'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana',
  'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota',
  'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire',
  'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota',
  'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island',
  'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont',
  'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'
];

$('#the-basics .typeahead').typeahead({
  hint: true,
  highlight: true,
  minLength: 1
},
{
  name: 'states',
  source: substringMatcher(states)
});

Open in new window


If you have a lot of data, there is an example for pulling in remote data http://twitter.github.io/typeahead.js/examples/#remote
var bestPictures = new Bloodhound({
  datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
  queryTokenizer: Bloodhound.tokenizers.whitespace,
  prefetch: '../data/films/post_1960.json',
  remote: {
    url: '../data/films/queries/%QUERY.json',
    wildcard: '%QUERY'
  }
});

$('#remote .typeahead').typeahead(null, {
  name: 'best-pictures',
  display: 'value',
  source: bestPictures
});

Open in new window

I have 10,000 files of 100 kb of each file size and want to have type-ahead search. Is the above will be faster and fetch the results in a second ?
i want everything should be saved in local machine or local storage and not in remote. want to bundle and give it as search with static text. the text will not be modified anytime in the future.
Then the example I gave you will be perfect.
but you have said - pulling in remote data

Can you please help me with a HTML file, sample. txt and bundle as zip file so that will download and test and confirm it?
I am confused, do you want to use remote data or not?  In any case, I gave you both examples. Try them on your own with your own data. Is this something you want to do on your own? Or do you want hire somebody to do this for you?
I want to use local data and not remote data but the data is huge...Do i need to hardcode in the above or can refer individual text files? Basically i am having everything in .txt file format
Hard code your text file.
Then the size of this file will be very huge. i have 10,000 text files. Do you want me to copy all of them and paste inside this single js file..Please suggestion how to deals with actual files or it's ok if it can handle such a huge file size..
That sounds like it is too many.  I would suggest getting the data into a database for this.  If files are always changing, being added etc, then you may be better off buying an off the shelf software do manage documents or keep the files in something like Google Drive and use the associated api do search.
Files are static and it will never change at any point of time. In that case which would be the right option. Will the above will handle.
There are 2 parts to this question.  One is using a typeahead feature where you access a data source by searching just a few characters and have results displayed. I think that is what I showed you so far.

The other part is the actual data source and that can be anything from a relational database to a group of files. I am not versed on searching a lot of documents like this vs a single datasource like MS SQL Server. If you choose search through documents like that, you will need to use some type of third party server software that index's all of the documents.

Here is a good primer article that goes over some different options https://medium.com/dev-channel/how-to-add-full-text-search-to-your-website-4e9c80ce2bf4
https://helpdeskgeek.com/how-to/search-inside-multiple-text-files-at-once/
https://docs.microsoft.com/en-us/rest/api/searchservice/search-documents

There are some options for you to look over and decide what will be best in your own use case.
Do you still need help with this question?
Yes, still not sure how to bring up an application with these features? any open source is available
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.