Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: Autocomplete / matcher from the browser with Opensearch #89

Open
eklem opened this issue May 23, 2015 · 11 comments
Open

Comments

@eklem
Copy link
Collaborator

eklem commented May 23, 2015

So, gotten Opensearch.xml to work with the browser search box over at life-index, but need a little more to get the autocomplete to work fully.

Today the respons JSON is an array of suggested search words.
skjermbilde 2015-05-23 kl 21 52 30

From the Opensearch XML documentation for suggestions it seems I need to alter the JSON a bit. I need the existing list

[  
   "test",
   "testing",
   "tests",
   "tested",
   "test2"",
   "test2",
   "test\\tools\\bench",
   "testcase",
   "test1"",
   "testdata"
]

to look like

[  
   "test",
   [  
      "test",
      "testing",
      "tests",
      "tested",
      "test2"",
      "test2",
      "test\\tools\\bench",
      "testcase",
      "test1"",
      "testdata"
   ]
]

Where the first array consists of the query or beginsWith and then the array of suggestions. My question is if you have an idea on how easy it would be to make this a part of the existing Norch without breaking anything?

Before you do anything, I can test with some dummy-JSON to be sure this is actually working for the browser.

@eklem
Copy link
Collaborator Author

eklem commented May 23, 2015

Ok, tested it with a static suggestions-file. And it works!
skjermbilde 2015-05-23 kl 22 32 10

The browser needs the query or beginsWith back from the matcher in order to list out the autocomplete. But great news =)

The suggestions-file contained this JSON:

[  
   "test",
   [  
      "test",
      "testing",
      "tests",
      "tested",
      "test2"",
      "test2",
      "test\\tools\\bench",
      "testcase",
      "test1"",
      "testdata"
   ]
]

And it kicked in when I had typed test.

@eklem
Copy link
Collaborator Author

eklem commented May 24, 2015

Got it working! Do you want a pull request? Small change, or actually addition, in norch.js:

The old matcher is like this:

  this.app.get('/matcher', function(req, res) {
    that.si.match(req.query['beginsWith'], function(err, matches) {
      res.send(matches);
    });
  });

The Opensearch suggestions like this (addition):

  this.app.get('/opensearchsuggests', function(req, res) {
    that.si.match(req.query['beginsWith'], function(err, matches) {
      res.send([req.query.beginsWith, matches]);
    });
  });

Screendumps from test:
skjermbilde 2015-05-24 kl 12 31 10

skjermbilde 2015-05-24 kl 12 31 27

@fergiemcdowall
Copy link
Owner

@eklem did you ever make that PR, or have any code that is PRable? :)

@eklem
Copy link
Collaborator Author

eklem commented Aug 21, 2015

Haven't made it. It's slightly hackish, but I think it's a good first step to add it, and then make it better. I'll do a PR, and you can decide to use it or not.

@fergiemcdowall
Copy link
Owner

OK! :)

@eklem
Copy link
Collaborator Author

eklem commented Aug 28, 2015

Not getting it to work in Mozilla anymore, so have to investigate a little.

@fergiemcdowall
Copy link
Owner

Ahh- the matcher API has changed ever-so-slightly, a call to the matcher now looks like this: http://localhost:3030/matcher?match={"beginsWith":"usa"}

There are also a few extra options- see the search-index docs for more info

@eklem
Copy link
Collaborator Author

eklem commented Aug 30, 2015

I'm still on an old version, so that shouldn't matter. It stopped working on Mozilla for Android, but desktop is fine.

@eklem
Copy link
Collaborator Author

eklem commented Aug 30, 2015

But, I'll leave the Android version for now and try adding the stuff needed.

@fergiemcdowall
Copy link
Owner

This is a great usecase for creating a query-result pipeline

@fergiemcdowall fergiemcdowall changed the title Autocomplete / matcher from the browser with Opensearch Documentation: Autocomplete / matcher from the browser with Opensearch Nov 11, 2016
@fergiemcdowall
Copy link
Owner

Another query-pipeline case is #124

@fergiemcdowall fergiemcdowall added this to the v1.x.x milestone Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants