SEARCH-273

- Added new library
- New attachments implementation
This commit is contained in:
Keerthi Niranjan 2017-10-06 13:00:25 +05:30
parent f72e0b7db6
commit 718459c201
9 changed files with 42 additions and 9 deletions

View File

@ -42,6 +42,10 @@
<label for="query">Query:</label><input id="query" size=60> <label for="query">Query:</label><input id="query" size=60>
</div> </div>
<br> <br>
<div>
<label for="has">Has:</label><input id="has">
</div>
<br>
<div> <div>
<label for="offset">Offset:</label><input id="offset" type="number" value="0" size=5> <label for="offset">Offset:</label><input id="offset" type="number" value="0" size=5>
<label for="limit">Limit:</label><input id="limit" type="number" value="25" size=5> <label for="limit">Limit:</label><input id="limit" type="number" value="25" size=5>
@ -99,7 +103,7 @@
</div> </div>
<script> <script>
var search = new ssf.Search("7078106230763", "7078106230763"); var search = new ssf.Search("7078106230763", "k2rbHBd5CgU3/PKLFUKUYkmuhCiL2Gw2bnsD7MdaZrU=");
var buttonEl = document.getElementById('search'); var buttonEl = document.getElementById('search');
var merge = document.getElementById('merge'); var merge = document.getElementById('merge');
var buttonIndex = document.getElementById('index'); var buttonIndex = document.getElementById('index');
@ -117,6 +121,7 @@
var realTimeIndexing = document.getElementById('realTimeIndexing'); var realTimeIndexing = document.getElementById('realTimeIndexing');
var batchNumber = document.getElementById('batchNumber'); var batchNumber = document.getElementById('batchNumber');
var timestamp = document.getElementById('getLatestMessageTimestamp'); var timestamp = document.getElementById('getLatestMessageTimestamp');
var has = document.getElementById('has');
buttonIndex.addEventListener('click', function () { buttonIndex.addEventListener('click', function () {
@ -146,7 +151,8 @@
if (threadIdEl.value && threadIdEl.value !== "" && threadIdEl.value.replace(/ /g, "").length > 0) { if (threadIdEl.value && threadIdEl.value !== "" && threadIdEl.value.replace(/ /g, "").length > 0) {
threadIdObj = JSON.parse(threadIdEl.value); threadIdObj = JSON.parse(threadIdEl.value);
} }
search.searchQuery(queryEl.value, senderIdObj, threadIdObj, null, startDate, endDate, limitEl.value, offsetEl.value, 0).then(function (result) { let _has = has.value || null;
search.searchQuery(queryEl.value, senderIdObj, threadIdObj, _has, startDate, endDate, limitEl.value, offsetEl.value, 0).then(function (result) {
if (result.messages.length < 1) { if (result.messages.length < 1) {
resultsEl.innerHTML = "No results found" resultsEl.innerHTML = "No results found"
} }

View File

@ -219,7 +219,7 @@ class Search {
* @param {String} query * @param {String} query
* @param {Array} senderIds * @param {Array} senderIds
* @param {Array} threadIds * @param {Array} threadIds
* @param {String} attachments * @param {String} fileType
* @param {String} startDate * @param {String} startDate
* @param {String} endDate * @param {String} endDate
* @param {Number} limit * @param {Number} limit
@ -227,7 +227,7 @@ class Search {
* @param {Number} sortOrder * @param {Number} sortOrder
* @returns {Promise} * @returns {Promise}
*/ */
searchQuery(query, senderIds, threadIds, attachments, startDate, searchQuery(query, senderIds, threadIds, fileType, startDate,
endDate, limit, offset, sortOrder) { endDate, limit, offset, sortOrder) {
let _limit = limit; let _limit = limit;
@ -245,7 +245,7 @@ class Search {
return; return;
} }
let q = Search.constructQuery(query, senderIds, threadIds); let q = Search.constructQuery(query, senderIds, threadIds, fileType);
if (q === undefined) { if (q === undefined) {
reject(new Error('Search query error')); reject(new Error('Search query error'));
@ -282,6 +282,7 @@ class Search {
try { try {
let ret = returnedResult.readCString(); let ret = returnedResult.readCString();
resolve(JSON.parse(ret)); resolve(JSON.parse(ret));
console.log(JSON.parse(ret));
} finally { } finally {
libSymphonySearch.symSEFreeResult(returnedResult); libSymphonySearch.symSEFreeResult(returnedResult);
} }
@ -326,9 +327,10 @@ class Search {
* @param {String} searchQuery * @param {String} searchQuery
* @param {Array} senderId * @param {Array} senderId
* @param {Array} threadId * @param {Array} threadId
* @param fileType
* @returns {string} * @returns {string}
*/ */
static constructQuery(searchQuery, senderId, threadId) { static constructQuery(searchQuery, senderId, threadId, fileType) {
let query = ""; let query = "";
if(searchQuery !== undefined) { if(searchQuery !== undefined) {
@ -346,16 +348,41 @@ class Search {
hashCashTagQuery += ")"; hashCashTagQuery += ")";
} }
let hasAttachments = false;
let additionalAttachmentQuery = "";
if(fileType) {
hasAttachments = true;
if(fileType === "attachment") {
additionalAttachmentQuery = "(hasfiles:true)";
} else {
additionalAttachmentQuery = "(filetype:(" + fileType +"))";
}
}
if (query.length > 0 ) { if (query.length > 0 ) {
q = "(text:(" + query + ")" + hashCashTagQuery + ")"; q = "((text:(" + query + "))" + hashCashTagQuery ;
if(hasAttachments) {
q += " OR (filename:(" + query + "))" ;
}
q = q + ")";
} }
q = Search.appendFilterQuery(q, "senderId", senderId); q = Search.appendFilterQuery(q, "senderId", senderId);
q = Search.appendFilterQuery(q, "threadId", threadId); q = Search.appendFilterQuery(q, "threadId", threadId);
if(q === "") { if(q === "") {
q = undefined; //will be handled in the search function if(hasAttachments) {
q = additionalAttachmentQuery;
} else {
q = undefined; //will be handled in the search function
}
} else {
if(hasAttachments){
q = q + " AND " + additionalAttachmentQuery
}
} }
console.log(q);
return q; return q;
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -11,7 +11,7 @@
"demo-mac": "npm run prebuild && cross-env ELECTRON_DEV=true electron . --url=file://$(pwd)/demo/index.html", "demo-mac": "npm run prebuild && cross-env ELECTRON_DEV=true electron . --url=file://$(pwd)/demo/index.html",
"search-win": "npm run prebuild && cross-env ELECTRON_DEV=true electron . --url=file:///demo/search.html", "search-win": "npm run prebuild && cross-env ELECTRON_DEV=true electron . --url=file:///demo/search.html",
"search-mac": "npm run prebuild && cross-env ELECTRON_DEV=true electron . --url=file://$(pwd)/demo/search.html", "search-mac": "npm run prebuild && cross-env ELECTRON_DEV=true electron . --url=file://$(pwd)/demo/search.html",
"unpacked-mac": "npm run prebuild && npm run test && build --mac --dir", "unpacked-mac": "npm run prebuild && build --mac --dir",
"packed-mac": "npm run unpacked-mac && packagesbuild -v installer/mac/symphony-mac-packager.pkgproj", "packed-mac": "npm run unpacked-mac && packagesbuild -v installer/mac/symphony-mac-packager.pkgproj",
"unpacked-win": "npm run prebuild && npm run test && build --win --x64 --dir", "unpacked-win": "npm run prebuild && npm run test && build --win --x64 --dir",
"unpacked-win-x86": "npm run prebuild && npm run test && build --win --ia32 --dir", "unpacked-win-x86": "npm run prebuild && npm run test && build --win --ia32 --dir",