mirror of
https://github.com/simon987/sist2.git
synced 2025-12-11 14:38:54 +00:00
Rework document IDs
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import axios from "axios";
|
||||
import {ext, strUnescape, lum} from "./util";
|
||||
import CryptoES from 'crypto-es';
|
||||
|
||||
export interface EsTag {
|
||||
id: string
|
||||
@@ -30,7 +29,6 @@ export interface EsHit {
|
||||
_index: string
|
||||
_id: string
|
||||
_score: number
|
||||
_path_md5: string
|
||||
_type: string
|
||||
_tags: Tag[]
|
||||
_seq: number
|
||||
@@ -249,11 +247,6 @@ class Sist2Api {
|
||||
res.hits.hits.forEach((hit: EsHit) => {
|
||||
hit["_source"]["name"] = strUnescape(hit["_source"]["name"]);
|
||||
hit["_source"]["path"] = strUnescape(hit["_source"]["path"]);
|
||||
hit["_path_md5"] = CryptoES.MD5(
|
||||
hit["_source"]["path"] +
|
||||
(hit["_source"]["path"] ? "/" : "") +
|
||||
hit["_source"]["name"] + ext(hit)
|
||||
).toString();
|
||||
|
||||
this.setHitProps(hit);
|
||||
this.setHitTags(hit);
|
||||
@@ -380,8 +373,7 @@ class Sist2Api {
|
||||
return axios.post(`${this.baseUrl}tag/` + hit["_source"]["index"], {
|
||||
delete: false,
|
||||
name: tag,
|
||||
doc_id: hit["_id"],
|
||||
path_md5: hit._path_md5
|
||||
doc_id: hit["_id"]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -389,8 +381,7 @@ class Sist2Api {
|
||||
return axios.post(`${this.baseUrl}tag/` + hit["_source"]["index"], {
|
||||
delete: true,
|
||||
name: tag,
|
||||
doc_id: hit["_id"],
|
||||
path_md5: hit._path_md5
|
||||
doc_id: hit["_id"]
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,22 @@ export default Vue.extend({
|
||||
onThumbnailClick() {
|
||||
window.open(`/f/${this.doc._id}`, "_blank");
|
||||
},
|
||||
findByCustomField(field, id) {
|
||||
return {
|
||||
query: {
|
||||
bool: {
|
||||
must: [
|
||||
{
|
||||
match: {
|
||||
[field]: id
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
size: 1
|
||||
}
|
||||
},
|
||||
findById(id) {
|
||||
return {
|
||||
query: {
|
||||
@@ -103,6 +119,8 @@ export default Vue.extend({
|
||||
query = this.findById(this.$route.query.byId);
|
||||
} else if (this.$route.query.byName) {
|
||||
query = this.findByName(this.$route.query.byName);
|
||||
} else if (this.$route.query.by && this.$route.query.q) {
|
||||
query = this.findByCustomField(this.$route.query.by, this.$route.query.q)
|
||||
}
|
||||
|
||||
if (query) {
|
||||
|
||||
Reference in New Issue
Block a user