TagSpaces is an offline, open source, document manager with tagging support
Implemented new search feature.
HappyDayd7e3c5101e35
diff --git a/app/components/EntryProperties.js b/app/components/EntryProperties.jsindex ac09badcc..9da5f0e23 100644--- a/app/components/EntryProperties.js+++ b/app/components/EntryProperties.js@@ -518,7 +518,7 @@ class EntryProperties extends Component<Props, State> {</div><Paper className={classes.tags}><TagDropContainer entryPath={path}>- <TagsSelect tagQuery={tags} handleChange={this.handleChange} />+ <TagsSelect tags={tags} handleChange={this.handleChange} /></TagDropContainer></Paper></div>diff --git a/app/components/Search.js b/app/components/Search.jsindex 326aec129..4f3f18533 100644--- a/app/components/Search.js+++ b/app/components/Search.js@@ -70,18 +70,19 @@ type Props = {type State = {textQuery?: string,- tagQuery?: Array<Tag>,- tagConjunction?: string,+ tagsAND?: Array<Tag>,+ tagsOR?: Array<Tag>,+ tagsNOT?: Array<Tag>,fileTypes?: Array<string>,- tags?: Array<string>,lastModified?: Date | string};class Search extends React.Component<Props, State> {state = {textQuery: '',- tagQuery: [],- tagConjunction: 'OR',+ tagsAND: [],+ tagsOR: [],+ tagsNOT: [],fileTypes: FileTypeGroups.any,lastModified: ''};@@ -106,8 +107,9 @@ class Search extends React.Component<Props, State> {this.setState({textQuery: '',- tagQuery: [],- tagConjunction: 'OR',+ tagsAND: [],+ tagsOR: [],+ tagsNOT: [],fileTypes: FileTypeGroups.any},() => this.props.loadDirectoryContent(this.props.currentDirectory)@@ -115,20 +117,12 @@ class Search extends React.Component<Props, State> {};executeSearch = () => {- const tags = [];-- if (this.state.tagQuery) {- this.state.tagQuery.map((tag) => {- Object.entries(tag).map(([key, value]) => {- if (key === 'title') tags.push(value);- });- });- }const searchQuery: SearchQuery = {textQuery: this.state.textQuery,fileTypes: this.state.fileTypes,- tagConjunction: this.state.tagConjunction,- tags, // TODO put this.state.tagQuery Array<Tag> instead+ tagsAND: this.state.tagsAND,+ tagsOR: this.state.tagsOR,+ tagsNOT: this.state.tagsNOT,maxSearchResults: this.props.maxSearchResults};console.log('Search object: ' + JSON.stringify(searchQuery));@@ -179,51 +173,32 @@ class Search extends React.Component<Props, State> {}/></FormControl>+ <Typography variant="caption" style={{ marginTop: 10 }}>+ {i18n.t('core:mustContainTheseTags')}+ </Typography><FormControlclassName={classes.formControl}disabled={indexing}>- {/* <InputLabel htmlFor="searchTags">{i18n.t('core:searchTags')}</InputLabel> */}- <TagsSelect tagQuery={this.state.tagQuery} handleChange={this.handleChange} />- {/* <Input- id="tagQuery"- name="tagQuery"- placeholder={i18n.t('core:tagsWithInterval')}- value={this.state.tagQuery}- onKeyDown={this.startSearch}- onChange={this.handleInputChange}- /> */}+ <TagsSelect tags={this.state.tagsAND} handleChange={this.handleChange} tagSearchType={'tagsAND'} /></FormControl>+ <Typography variant="caption" style={{ marginTop: 10 }}>+ {i18n.t('core:atLeastOneOfTheseTags')}+ </Typography><FormControl- component="fieldset"className={classes.formControl}- disabled={indexing || !Pro}- title={i18n.t('core:thisFunctionalityIsAvailableInPro')}+ disabled={indexing}>- <FormHelperText>- {i18n.t('core:tagSearchType')}- </FormHelperText>- <RadioGroup- aria-label={i18n.t('core:tagSearchType')}- name="tagConjunction"- value={this.state.tagConjunction}- onChange={this.handleInputChange}- row- >- <FormControlLabel- value="OR"- control={<Radio />}- label={i18n.t('core:tagSearchOR')}- title={i18n.t('core:tagSearchORTitle')}- style={{ paddingRight: 20 }}- />- <FormControlLabel- value="AND"- control={<Radio />}- label={i18n.t('core:tagSearchAND')}- title={i18n.t('core:tagSearchANDTitle')}- />- </RadioGroup>+ <TagsSelect tags={this.state.tagsOR} handleChange={this.handleChange} tagSearchType={'tagsOR'} />+ </FormControl>+ <Typography variant="caption" style={{ marginTop: 10 }}>+ {i18n.t('core:noneOfTheseTags')}+ </Typography>+ <FormControl+ className={classes.formControl}+ disabled={indexing}+ >+ <TagsSelect tags={this.state.tagsNOT} handleChange={this.handleChange} tagSearchType={'tagsNOT'} /></FormControl><FormControlclassName={classes.formControl}diff --git a/app/components/TagsSelect.js b/app/components/TagsSelect.jsindex 28a7e37e4..a926a7ac1 100644--- a/app/components/TagsSelect.js+++ b/app/components/TagsSelect.js@@ -178,7 +178,8 @@ const components = {type Props = {classes: Object,theme: Object,- tagQuery: string,+ tags: Array<tag>,+ tagSearchType: string,handleChange: () => void,allTags: Array<Tag>};@@ -191,14 +192,14 @@ class TagsSelect extends React.Component<Props> {// console.groupEnd();if (actionMeta.action === 'select-option') {- this.props.handleChange('tagQuery', newValue, actionMeta.action);+ this.props.handleChange(this.props.tagSearchType, newValue, actionMeta.action);} else if (actionMeta.action === 'create-option') {this.props.allTags.push(newValue);- this.props.handleChange('tagQuery', newValue, actionMeta.action);+ this.props.handleChange(this.props.tagSearchType, newValue, actionMeta.action);} else if (actionMeta.action === 'remove-value') {- this.props.handleChange('tagQuery', newValue, actionMeta.action);+ this.props.handleChange(this.props.tagSearchType, newValue, actionMeta.action);} else if (actionMeta.action === 'clear') {- this.props.handleChange('tagQuery', [], actionMeta.action);+ this.props.handleChange(this.props.tagSearchType, [], actionMeta.action);}};@@ -213,7 +214,7 @@ class TagsSelect extends React.Component<Props> {classes,theme,allTags,- tagQuery,+ tags,defaultBackgroundColor,defaultTextColor} = this.props;@@ -253,7 +254,7 @@ class TagsSelect extends React.Component<Props> {shrink: true,},}} */- value={tagQuery}+ value={tags}onChange={this.handleChange}// onInputChange={this.handleInputSelectChange}// onCreateOption={this.handleCreate}diff --git a/app/components/dialogs/AddRemoveTagsDialog.js b/app/components/dialogs/AddRemoveTagsDialog.jsindex f50b25c5d..b0a2fd962 100644--- a/app/components/dialogs/AddRemoveTagsDialog.js+++ b/app/components/dialogs/AddRemoveTagsDialog.js@@ -100,7 +100,7 @@ class AddRemoveTagsDialog extends React.Component<Props, State> {)}renderContent={() => (<DialogContent style={{ minHeight: 330 }}>- <TagsSelect tagQuery={newlyAddedTags} handleChange={this.handleChange} />+ <TagsSelect tags={newlyAddedTags} handleChange={this.handleChange} /><List dense style={{ width: 550 }}>{selectedEntries.length > 0 && selectedEntries.map((entry) => (<ListItem title={entry.path}>diff --git a/app/locales/ar/core.json b/app/locales/ar/core.jsonindex f5f465ba4..3ff36b4ce 100644--- a/app/locales/ar/core.json+++ b/app/locales/ar/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/bg/core.json b/app/locales/bg/core.jsonindex b1f3a056a..ccaf71792 100644--- a/app/locales/bg/core.json+++ b/app/locales/bg/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/ca/core.json b/app/locales/ca/core.jsonindex 441ff43fe..41ba6bc28 100644--- a/app/locales/ca/core.json+++ b/app/locales/ca/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/cs/core.json b/app/locales/cs/core.jsonindex 1b3b86737..039f876e7 100644--- a/app/locales/cs/core.json+++ b/app/locales/cs/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/da_DK/core.json b/app/locales/da_DK/core.jsonindex 3eab5d183..24b267ace 100644--- a/app/locales/da_DK/core.json+++ b/app/locales/da_DK/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/de_DE/core.json b/app/locales/de_DE/core.jsonindex 09b422598..a6bda312f 100644--- a/app/locales/de_DE/core.json+++ b/app/locales/de_DE/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "TagSpaces verlassen","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/el/core.json b/app/locales/el/core.jsonindex 0106e938b..07d64faea 100644--- a/app/locales/el/core.json+++ b/app/locales/el/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/en/core.json b/app/locales/en/core.jsonindex b192fad93..c889ad5ab 100644--- a/app/locales/en/core.json+++ b/app/locales/en/core.json@@ -338,7 +338,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",@@ -391,5 +390,8 @@"singleClickOpenInternally": "Single click opens file internally","singleClickOpenExternally": "Single click opens file externally","parentDirNotInLocation": "Unable to navigate! Parent folder not in the current location.",+ "mustContainTheseTags": "Must contain all of these tags",+ "atLeastOneOfTheseTags": "At least one of these tags",+ "noneOfTheseTags": "None of these tags","-": "-"}diff --git a/app/locales/en_US/core.json b/app/locales/en_US/core.jsonindex ca1a8ff2b..9508d2f9a 100644--- a/app/locales/en_US/core.json+++ b/app/locales/en_US/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/eo/core.json b/app/locales/eo/core.jsonindex 7e8e8b243..14baaf45d 100644--- a/app/locales/eo/core.json+++ b/app/locales/eo/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/es/core.json b/app/locales/es/core.jsonindex 11cc3d348..d8ffb423a 100644--- a/app/locales/es/core.json+++ b/app/locales/es/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/fa/core.json b/app/locales/fa/core.jsonindex 271d9379c..12ce3445e 100644--- a/app/locales/fa/core.json+++ b/app/locales/fa/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/fr/core.json b/app/locales/fr/core.jsonindex 478722067..16e42b74f 100644--- a/app/locales/fr/core.json+++ b/app/locales/fr/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Voir TagSpaces","quitTagSpaces": "Quitter TagSpaces","switchTheme": "Changer de thème",- "tagSearchType": "Recherche par type d'étiquette","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/hu/core.json b/app/locales/hu/core.jsonindex 9a53d1add..686de98d4 100644--- a/app/locales/hu/core.json+++ b/app/locales/hu/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Mutasd a TagSpaces-t","quitTagSpaces": "Kilépés a TagSpaces-ből","switchTheme": "Téma váltása",- "tagSearchType": "Címke kereső típusa","bucketName": "Bucket neve","regionSearch": "Régió keresése","secretAccessKey": "Titkos hozzáférési kulcs",diff --git a/app/locales/hy/core.json b/app/locales/hy/core.jsonindex 07efc6a83..d648889d4 100644--- a/app/locales/hy/core.json+++ b/app/locales/hy/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Ցույց տալ TagSpaces-ը","quitTagSpaces": "Փակել TagSpaces-ը","switchTheme": "Փոխել թեման",- "tagSearchType": "Պիտակի որոնման տեսակ","bucketName": "Դույլի անուն","regionSearch": "Որոնել տարածք","secretAccessKey": "Մատչումի գաղտնի բանալի",diff --git a/app/locales/id_ID/core.json b/app/locales/id_ID/core.jsonindex f0aa1f0bd..b5e1351e9 100644--- a/app/locales/id_ID/core.json+++ b/app/locales/id_ID/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/it/core.json b/app/locales/it/core.jsonindex e4952633e..2e857da17 100644--- a/app/locales/it/core.json+++ b/app/locales/it/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Mostra TagSpaces","quitTagSpaces": "Esci da TagSpaces","switchTheme": "Cambia tema",- "tagSearchType": "Tipo di ricerca etichette","bucketName": "Nome bucket","regionSearch": "Cerca in una regione","secretAccessKey": "Chiave di accesso segreto",diff --git a/app/locales/ja/core.json b/app/locales/ja/core.jsonindex a684c7124..7b38660e5 100644--- a/app/locales/ja/core.json+++ b/app/locales/ja/core.json@@ -333,7 +333,6 @@"showTagSpaces": "TagSpacesの表示","quitTagSpaces": "TagSpacesの終了","switchTheme": "テーマの切り替え",- "tagSearchType": "タグの検索タイプ","bucketName": "バケット名","regionSearch": "範囲の検索","secretAccessKey": "秘密のアクセスキー",diff --git a/app/locales/kk_KZ/core.json b/app/locales/kk_KZ/core.jsonindex 332af05c1..a3d376c05 100644--- a/app/locales/kk_KZ/core.json+++ b/app/locales/kk_KZ/core.json@@ -334,6 +334,5 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","-": "-"}diff --git a/app/locales/ko/core.json b/app/locales/ko/core.jsonindex 494e19135..10292f069 100644--- a/app/locales/ko/core.json+++ b/app/locales/ko/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/mt/core.json b/app/locales/mt/core.jsonindex a6cdb37d1..e23f8fdc0 100644--- a/app/locales/mt/core.json+++ b/app/locales/mt/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/nl_NL/core.json b/app/locales/nl_NL/core.jsonindex fa9533dd1..5b4c48145 100644--- a/app/locales/nl_NL/core.json+++ b/app/locales/nl_NL/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/pl/core.json b/app/locales/pl/core.jsonindex 6d63531c8..14fb921a9 100644--- a/app/locales/pl/core.json+++ b/app/locales/pl/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/pt_BR/core.json b/app/locales/pt_BR/core.jsonindex c9b3f23aa..686702144 100644--- a/app/locales/pt_BR/core.json+++ b/app/locales/pt_BR/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/pt_PT/core.json b/app/locales/pt_PT/core.jsonindex 2a318c7ec..21074f65c 100644--- a/app/locales/pt_PT/core.json+++ b/app/locales/pt_PT/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/ru/core.json b/app/locales/ru/core.jsonindex 4fcc7cdd2..7b042861c 100644--- a/app/locales/ru/core.json+++ b/app/locales/ru/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Показать TagSpaces","quitTagSpaces": "Выйти из TagSpaces","switchTheme": "Переключить тему",- "tagSearchType": "Тип поиска по тегам","bucketName": "Название корзины","regionSearch": "Поиск региона","secretAccessKey": "Секретный ключ доступа",diff --git a/app/locales/sk_SK/core.json b/app/locales/sk_SK/core.jsonindex b6f3063c0..b6a803d4a 100644--- a/app/locales/sk_SK/core.json+++ b/app/locales/sk_SK/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/sv/core.json b/app/locales/sv/core.jsonindex a529d6d49..60c0633af 100644--- a/app/locales/sv/core.json+++ b/app/locales/sv/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/tr/core.json b/app/locales/tr/core.jsonindex 8994580b1..cfb09b149 100644--- a/app/locales/tr/core.json+++ b/app/locales/tr/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/uk/core.json b/app/locales/uk/core.jsonindex 5aad5614b..d571e599f 100644--- a/app/locales/uk/core.json+++ b/app/locales/uk/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/vi/core.json b/app/locales/vi/core.jsonindex ac59cf364..3053d6829 100644--- a/app/locales/vi/core.json+++ b/app/locales/vi/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/zh_CN/core.json b/app/locales/zh_CN/core.jsonindex 77d62d261..dd936ea40 100644--- a/app/locales/zh_CN/core.json+++ b/app/locales/zh_CN/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/zh_HK/core.json b/app/locales/zh_HK/core.jsonindex ca1a8ff2b..9508d2f9a 100644--- a/app/locales/zh_HK/core.json+++ b/app/locales/zh_HK/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/locales/zh_TW/core.json b/app/locales/zh_TW/core.jsonindex 4b080debf..6e5945dc0 100644--- a/app/locales/zh_TW/core.json+++ b/app/locales/zh_TW/core.json@@ -333,7 +333,6 @@"showTagSpaces": "Show TagSpaces","quitTagSpaces": "Quit TagSpaces","switchTheme": "Switch theme",- "tagSearchType": "Tag search type","bucketName": "Bucket Name","regionSearch": "Search a region","secretAccessKey": "Secret Access Key",diff --git a/app/services/search.js b/app/services/search.jsindex 503b0d47e..f84fa79a7 100644--- a/app/services/search.js+++ b/app/services/search.js@@ -47,8 +47,9 @@ export const FileTypeGroups = {export type SearchQuery = {textQuery?: string,fileTypes?: Array<string>,- tagConjunction?: 'AND' | 'OR',- tags?: Array<string>, // TODO Array<Tag>+ tagsAND?: Array<Tag>,+ tagsOR?: Array<Tag>,+ tagsNOT?: Array<Tag>,lastChanged?: Date,maxSearchResults?: number};@@ -110,62 +111,86 @@ const fuseOptions = {}]};-function constructTagQuery(searchQuery: SearchQuery): string {- let tagQuery = '';- if (searchQuery.tags && searchQuery.tags.length >= 1) {- tagQuery = 'tags[? (';- searchQuery.tags.map(tag => {- const cleanedTag = tag.trim(); // .toLowerCase();- if (cleanedTag.length > 0) {- tagQuery += 'title==\'' + cleanedTag + '\' || ';+// Constructs the string for the JMESPath search query. We first filter for all ORTags, then continuously pipe the result in to the+// filters for all AND and NOT tags. The Pro version can pipe the result into an additional filter for extension instead of tags.title.+// The final string for the tag search should look like this:+// index[? tags[? title=='ORTag1' || title=='ORTag2']] | [? tags[? title=='ANDTag1']] | [? tags[? title=='ANDTag2']] | [?!(tags[? title=='NOTTag1'])] | [?!(tags[? title=='NOTTag2'])] | extensionFilter+function constructjmespathQuery(searchQuery: SearchQuery): string {+ let jmespathQuery = '';+ const ANDtagsExist = searchQuery.tagsAND && searchQuery.tagsAND.length >= 1;+ const ORtagsExist = searchQuery.tagsOR && searchQuery.tagsOR.length >= 1;+ const NOTtagsExist = searchQuery.tagsNOT && searchQuery.tagsNOT.length >= 1;+ if (ANDtagsExist || ORtagsExist || NOTtagsExist) {+ jmespathQuery = 'index[?';++ if (ORtagsExist) {+ jmespathQuery += ' tags[? ';+ searchQuery.tagsOR.forEach(tag => {+ const cleanedTagTitle = tag.title.trim(); // .toLowerCase();+ if (cleanedTagTitle.length > 0) {+ jmespathQuery += 'title==\'' + cleanedTagTitle + '\' || ';+ }+ return true;+ });+ }++ if (ANDtagsExist) {+ if (jmespathQuery.endsWith(' || ')) {+ jmespathQuery = jmespathQuery.substring(0, jmespathQuery.length - 4) + ']] | [? tags[? ';+ } else {+ jmespathQuery += ' tags[? ';}- return true;- });- if (tagQuery.endsWith('|| ')) {- tagQuery = tagQuery.substring(0, tagQuery.length - 3) + ') ]';+ searchQuery.tagsAND.forEach(tag => {+ const cleanedTagTitle = tag.title.trim(); // .toLowerCase();+ if (cleanedTagTitle.length > 0) {+ jmespathQuery += 'title==\'' + cleanedTagTitle + '\']] | [? tags[? ';+ }+ });}- }- return tagQuery;-}-function constructFuseQuery(searchQuery: SearchQuery): string {- if (!searchQuery) return '';- let fuseQuery = (searchQuery.textQuery) ? searchQuery.textQuery : '';- if (searchQuery.tags && searchQuery.tags.length >= 1) {- searchQuery.tags.map(tag => {- const cleanedTag = tag.trim().toLowerCase();- fuseQuery = fuseQuery + ' ' + cleanedTag;- return true;- });+ if (NOTtagsExist) {+ if (jmespathQuery.endsWith(' || ')) {+ jmespathQuery = jmespathQuery.substring(0, jmespathQuery.length - 4) + ']] | [?!(tags[? ';+ } else if (jmespathQuery.endsWith('[? tags[? ')) {+ jmespathQuery = jmespathQuery.substring(0, jmespathQuery.length - 10) + '[?!(tags[? ';+ } else {+ jmespathQuery += '!(tags[? ';+ }+ searchQuery.tagsNOT.forEach(tag => {+ const cleanedTagTitle = tag.title.trim(); // .toLowerCase();+ if (cleanedTagTitle.length > 0) {+ jmespathQuery += 'title==\'' + cleanedTagTitle + '\'])] | [?!(tags[? ';+ }+ return true;+ });+ }++ if (jmespathQuery.endsWith(' || ')) {+ jmespathQuery = jmespathQuery.substring(0, jmespathQuery.length - 4) + ']]';+ } else if (jmespathQuery.endsWith(' | [? tags[? ')) {+ jmespathQuery = jmespathQuery.substring(0, jmespathQuery.length - 13);+ } else if (jmespathQuery.endsWith(' | [?!(tags[? ')) {+ jmespathQuery = jmespathQuery.substring(0, jmespathQuery.length - 14);+ }}- return fuseQuery;++ // if (Pro) ...++ return jmespathQuery;}export default class Search {static searchLocationIndex = (locationContent: Array<Object>, searchQuery: SearchQuery): Promise<Array<Object> | []> => new Promise((resolve) => {- // let result = jmespath.search({ index: locationContent }, "index[?contains(name, '" + searchQuery.textQuery + "')]");- // ?tags[?title=='todo' || title=='high'- // index[?extension=='png' || extension=='jpg']-+ const jmespathQuery = constructjmespathQuery(searchQuery);+ let jmespathResults;let results;- const extensionQuery = Pro ? Pro.Search.constructFileTypeQuery(searchQuery) : '';- const tagQuery = Pro ? Pro.Search.constructTagQuery(searchQuery) : constructTagQuery(searchQuery);- let jmespathQuery;-- if (extensionQuery.length > 1 && tagQuery.length > 1) { // extension query and tags available- jmespathQuery = 'index[? ' + extensionQuery + ' && ' + tagQuery + ']';- } else if (extensionQuery.length <= 1 && tagQuery.length > 1) { // only tags- jmespathQuery = 'index[? ' + tagQuery + ']';- } else if (extensionQuery.length > 1 && tagQuery.length <= 1) { // only extension query- jmespathQuery = 'index[? ' + extensionQuery + ']';- }if (jmespathQuery) {console.log('jmespath query: ' + jmespathQuery);console.time('jmespath');- results = jmespath.search({ index: results || locationContent }, jmespathQuery);+ jmespathResults = jmespath.search({ index: jmespathResults || locationContent }, jmespathQuery);console.timeEnd('jmespath');- console.log('jmespath results: ' + results.length);+ console.log('jmespath results: ' + jmespathResults.length);}// if (Pro && Pro.Search.filterIndex) {@@ -173,12 +198,13 @@ export default class Search {// }if (searchQuery.textQuery && searchQuery.textQuery.length > 1) {- const fuseQuery = constructFuseQuery(searchQuery);- console.log('fuse query: ' + fuseQuery);+ console.log('fuse query: ' + searchQuery.textQuery);console.time('fuse');- const fuse = new Fuse(results || locationContent, fuseOptions);- results = fuse.search(fuseQuery);+ const fuse = new Fuse(jmespathResults || locationContent, fuseOptions);+ results = fuse.search(searchQuery.textQuery);console.timeEnd('fuse');+ } else {+ results = jmespathResults;}if (results) {