-
Notifications
You must be signed in to change notification settings - Fork 208
/
Copy pathmlt-query-test.ts
58 lines (54 loc) · 1.52 KB
/
mlt-query-test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* Testing support for http://wiki.apache.org/solr/MoreLikeThis
*/
import { assert } from 'chai';
import * as figc from 'figc';
import { createClient } from '../lib/solr';
import * as sassert from './utils/sassert';
import { MltOptions } from '../lib/types';
import { dataOk } from './utils/sassert';
const config = figc(__dirname + '/config.json');
const client = createClient(config.client);
[config.client.path, config.client.core].join('/').replace(/\/$/, '');
describe('Client#createQuery', function () {
describe('#mlt(options), callback)', function () {
it('should create a MoreLikeThis query', async function () {
const options: MltOptions = {
on: true,
fl: ['content', 'title'],
count: 15,
mintf: 0,
mindf: 0,
minwl: 0,
maxwl: 1500,
maxqt: 1500,
maxntp: 1500,
boost: true,
qf: 1,
};
const query = client
.query()
.mlt(options)
.q({ title_t: 'test' })
.debugQuery();
const data = await client.search(query);
dataOk(data);
assert.deepEqual(data.responseHeader.params, {
'mlt.minwl': '0',
'mlt.fl': 'content,title',
'mlt.boost': 'true',
'mlt.mintf': '0',
'mlt.qf': '1',
mlt: 'true',
'mlt.maxwl': '1500',
'mlt.maxntp': '1500',
'mlt.maxqt': '1500',
wt: 'json',
'mlt.mindf': '0',
'mlt.count': '15',
debugQuery: 'true',
q: 'title_t:test',
});
});
});
});