question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot make a search on all fields

See original GitHub issue

Hello, i am new with search index in node JS and i tried to make a search engine from Json file but it doesn’t work for all fields. here is my code

var express = require('express');
var router = express.Router();
var fs = require('fs')
var JSONStream = require('JSONStream')
var options = {
    "batchSize": 1000,
        "fieldedSearch": true,
        "preserveCase": false,
        "storeable": true,
        "searchable": true,
        "indexPath": "data",
        "logLevel": "error",
        "nGramLength": [1]
}
var searchIndex = require('search-index')
var dataset = require('../node_modules/reuters-21578-json/data/justTen/justTen.json')


/* GET users listing. */
router.get('/', function(req, res, next) {


    searchIndex(options, function(err, si) {
       // si.flush(function(err) {
        // if (!err) console.log('success!')
        //})
        si.concurrentAdd(dataset, {}, function(err) {
            if (!err) console.log('indexed!')
            else return callback(err, {})
            console.log(si.fields);
            console.log('doing a test search...')
            si.search({"query": [
                {AND: {'*':["COCOA"]}}]} , function(err, results) {
                console.log('total hits: ' + results.totalHits)
                for (var i = 0; i < results.hits.length; i++) {
                    console.log()
                    console.log('* ' + results.hits[i].document.title + ' *')
                    console.log('* ' + results.hits[i].document.date + ' *')
                    console.log()
                    console.log('--------------------')
                }
                res.status(200).send(results.hits)
            })
        })



    });

    //res.end();


    // res.end(results.hits);
});

module.exports = router;

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Samy78commented, Jul 23, 2017

ok thank you, now it works, but can i stream json file instead of str file ?

0reactions
Samy78commented, Jul 23, 2017

ok thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to search over all fields and return every document ...
I have a index with multiple documents with several fields. I want to be able to search over all the fields running a...
Read more >
Simple Kibana "term query" not searching the all the fields
The problem now is that Kibana doesn't search log.message using term queries (just using "query here" in the Kibana search bar without explicit ......
Read more >
FIND Query not searching IN ALL FIELDS RETURN
I want to be able to enter an account name and retrieve a list of opportunities. This works for opportunity name only, but...
Read more >
How do i search all fields at once? - Jira - Atlassian Community
1 answer. You can use "text ~ xyz" to search all the text based fields, but select list fields are different and can't...
Read more >
Can't search all contact fields - Salesforce Stack Exchange
I am an administrator with the Nonprofit CRM version of Salesforce I am trying to make a contact database for people who have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found