Improve indentation in quickstart
This commit is contained in:
@ -118,46 +118,48 @@ var perPage = request.params.per_page;
|
||||
var userQuery = request.params.search_query;
|
||||
var userId = request.session.userId;
|
||||
|
||||
client.search({
|
||||
index: 'posts',
|
||||
from: (pageNum - 1) * perPage,
|
||||
size: perPage,
|
||||
body: {
|
||||
query: {
|
||||
filtered: {
|
||||
query: {
|
||||
match: {
|
||||
// match the query agains all of
|
||||
// the fields in the posts index
|
||||
_all: userQuery
|
||||
}
|
||||
},
|
||||
filter: {
|
||||
// only return documents that are
|
||||
// public or owned by the current user
|
||||
or: [
|
||||
{
|
||||
term: { privacy: "public" }
|
||||
},
|
||||
{
|
||||
term: { owner: userId }
|
||||
}
|
||||
]
|
||||
var searchParams = {
|
||||
index: 'posts',
|
||||
from: (pageNum - 1) * perPage,
|
||||
size: perPage,
|
||||
body: {
|
||||
query: {
|
||||
filtered: {
|
||||
query: {
|
||||
match: {
|
||||
// match the query agains all of
|
||||
// the fields in the posts index
|
||||
_all: userQuery
|
||||
}
|
||||
},
|
||||
filter: {
|
||||
// only return documents that are
|
||||
// public or owned by the current user
|
||||
or: [
|
||||
{
|
||||
term: { privacy: "public" }
|
||||
},
|
||||
{
|
||||
term: { owner: userId }
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}, function (err, res) {
|
||||
if (err) {
|
||||
}
|
||||
};
|
||||
|
||||
client.search(searchParams, function (err, res) {
|
||||
if (err) {
|
||||
// handle error
|
||||
return;
|
||||
throw err;
|
||||
}
|
||||
|
||||
response.render('search_results', {
|
||||
results: res.hits.hits,
|
||||
page: pageNum,
|
||||
pages: Math.ceil(res.hits.total / perPage)
|
||||
})
|
||||
});
|
||||
});
|
||||
-----------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user