Elasticsearchのインデックス名をconfigで変更できるように (#5257)
This commit is contained in:
		
							parent
							
								
									fa2c7658a0
								
							
						
					
					
						commit
						1c273a0a75
					
				
					 4 changed files with 6 additions and 4 deletions
				
			
		|  | @ -28,6 +28,7 @@ export type Source = { | ||||||
| 		host: string; | 		host: string; | ||||||
| 		port: number; | 		port: number; | ||||||
| 		pass: string; | 		pass: string; | ||||||
|  | 		index?: string; | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
| 	autoAdmin?: boolean; | 	autoAdmin?: boolean; | ||||||
|  |  | ||||||
|  | @ -38,11 +38,11 @@ const client = config.elasticsearch ? new elasticsearch.Client({ | ||||||
| 
 | 
 | ||||||
| if (client) { | if (client) { | ||||||
| 	client.indices.exists({ | 	client.indices.exists({ | ||||||
| 		index: 'misskey_note' | 		index: config.elasticsearch.index || 'misskey_note', | ||||||
| 	}).then(exist => { | 	}).then(exist => { | ||||||
| 		if (!exist.body) { | 		if (!exist.body) { | ||||||
| 			client.indices.create({ | 			client.indices.create({ | ||||||
| 				index: 'misskey_note', | 				index: config.elasticsearch.index || 'misskey_note', | ||||||
| 				body: index | 				body: index | ||||||
| 			}); | 			}); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | @ -5,6 +5,7 @@ import { ApiError } from '../../error'; | ||||||
| import { Notes } from '../../../../models'; | import { Notes } from '../../../../models'; | ||||||
| import { In } from 'typeorm'; | import { In } from 'typeorm'; | ||||||
| import { ID } from '../../../../misc/cafy-id'; | import { ID } from '../../../../misc/cafy-id'; | ||||||
|  | import config from '../../../../config'; | ||||||
| 
 | 
 | ||||||
| export const meta = { | export const meta = { | ||||||
| 	desc: { | 	desc: { | ||||||
|  | @ -87,7 +88,7 @@ export default define(meta, async (ps, me) => { | ||||||
| 	: []; | 	: []; | ||||||
| 
 | 
 | ||||||
| 	const result = await es.search({ | 	const result = await es.search({ | ||||||
| 		index: 'misskey_note', | 		index: config.elasticsearch.index || 'misskey_note', | ||||||
| 		body: { | 		body: { | ||||||
| 			size: ps.limit!, | 			size: ps.limit!, | ||||||
| 			from: ps.offset, | 			from: ps.offset, | ||||||
|  |  | ||||||
|  | @ -434,7 +434,7 @@ function index(note: Note) { | ||||||
| 	if (note.text == null || config.elasticsearch == null) return; | 	if (note.text == null || config.elasticsearch == null) return; | ||||||
| 
 | 
 | ||||||
| 	es!.index({ | 	es!.index({ | ||||||
| 		index: 'misskey_note', | 		index: config.elasticsearch.index || 'misskey_note', | ||||||
| 		id: note.id.toString(), | 		id: note.id.toString(), | ||||||
| 		body: { | 		body: { | ||||||
| 			text: note.text.toLowerCase(), | 			text: note.text.toLowerCase(), | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue