sajari / sdk-js Goto Github PK
View Code? Open in Web Editor NEWOfficial repository of the Search.io SDK for JavaScript integration into web applications
Home Page: https://www.search.io
License: MIT License
Official repository of the Search.io SDK for JavaScript integration into web applications
Home Page: https://www.search.io
License: MIT License
When getting permission denied (usually because of a search from an unauthorised domain) we should be explicit in letting the user know, as this is not really error but more a misconfiguration.
We might need to come up with better names, but currently we have: allFilters(…)
, anyFilter(…)
, oneOfFilters(…)
, noneOfFilters(…)
.
Instead allow things like:
fieldFilter('event', '=', '100')
Could we even make this:
fieldFilter('event =', '100')
The full set of operations would include ^
(prefix), $
(suffix), ~
(contains), !~
(not contains).
The code has these symbols being translated into the wrong operations: https://github.com/sajari/sajari-sdk-js/blob/master/src/sajari.js#L115
Instead we should have ^
mapping to HAS_PREFIX
and $
mapping to HAS_SUFFIX
.
Currently we are not sending page meta back, e.g. data-sj-meta-key=val
props
Add function to generate a usable url from a token so users can use them easier
function formatToken(token) {
return 'https://www.sajari.com/token/' + token
}
Currently only the read functions are supported. Need to add the writes:
Not being passed to template as yet...
This causes a delay on the first key-press for a user. See https://stackoverflow.com/questions/29954037/why-is-an-options-request-sent-and-can-i-disable-it
Likely cause we send the Content-Type: application/json
header, which is not allowed. Only the following are allowed for the Content-Type
header:
I'm not really sure that it concern of the JS SDK. but...
When I add sorting to Query like that:
import { Client, Query, Tracking, fieldFilter, anyFilters, allFilters, sort } from 'sajari';
const client = new Client('projectName', 'collectionName');
const query = new Query();
const titleFilter = fieldFilter('title', '~', searchText);
const descriptionFilter = fieldFilter('body', '~', searchText);
const publishFilter = fieldFilter('publishedStatus', '=', 'true');
const sortQuery = sort('title'); // or any other field, or with '-'
query.sort(sortQuery);
query.limit(searchResultsLimit);
query.offset(searchOffset);
query.filter(allFilters([searchQuery, publishFilter]));
client.search(query, new Tracking(), (err, res) => {
...
});
it returns me 400 status code with the message:
Error during search: could not unmarshal request into proto: json: cannot unmarshal object into Go value of type []json.RawMessage
request to the API looks like that:
{
"request": {
"searchRequest": {
"limit": 10,
"sort": {
"field": "title",
"order": "ASC"
},
"offset": 0,
"filter": {
"combinator": {
"filters": [
{
"combinator": {
"filters": [
{
"field": {
"field": "title",
"value": {
"single": ""
},
"operator": "CONTAINS"
}
},
{
"field": {
"field": "body",
"value": {
"single": ""
},
"operator": "CONTAINS"
}
}
],
"operator": "ANY"
}
},
{
"field": {
"field": "publishedStatus",
"value": {
"single": "true"
},
"operator": "EQUAL_TO"
}
}
],
"operator": "ALL"
}
}
},
"tracking": {
"sequence": 0,
"query_id": "hjcbokdf7xgmfqhh",
"data": {
"sjID": "1502790432164.658192"
}
}
},
"metadata": {
"project": [
"projectName"
],
"collection": [
"collectionName"
],
"user-agent": [
"sdk-js-0.19.0"
]
}
}
Without sorting everything is ok.
Basic HTML based integration is working fine, but we need to test the query pkg works now since migrating everything over.
Creating a query object from api.query fails when a string is used as an argument.
query = api.query("foo");
This does not immediately fail, but causes errors when functions are called on the query object, such as filter, or maxresults.
Currently, no function which makes API request(s) have support for timeout leading to a clogged event loop for clients until the gateway itself sends a 504 Gateway Timeout (which understandably is pretty high for most use cases.)
Ideally, clients should be able to specify the maximum timeout they are willing to tolerate when calling functions from the library which make API requests.
Currently this is still using the old format, which is difficult to read and work with.
Could you please create and maintain actual tags and releases on GitHub (sync with the version that is placed on NPM)? It's confusing now.
People encoding their own queries is not a good idea.
JS currently doesn't send pid or GA ID.
Following convention, the SDK could check if the success / callback functions were passed down, or else return a Promise
.
This makes the sdk super useful on node.js as well.
On a side-note, in node the convention is to have a callback passed as a fn(error, result)
, and as the last param. Since this doesn't adhere to that, we can't use methods like bluebird.promisifyAll
to convert this callback based lib to a promise based one.
Currently we send back profiles, but store nothing locally. We should be storing locally and sending with queries where applicable.
I can't find working documentation for the SDK: https://doc.esdoc.org/github.com/sajari/sajari-sdk-js/ from README.md gives 403 Forbidden
.
Allow:
sort('-price')
Remove the constants from the exported API.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.