
358
3
부
애플리케이션
'_id': 'eHmWYG4BfVJ3yetiIs2m',
'_score': 45.704754,
'_source': {'title': 'Data collection'}}]}}
이제 쿼리 함수를 구축해보자.
Fields
인수는 필드 이름 및 부스트의 튜플 목록이다.
부스트
는
본질적으로 다른 필드에 대한 인덱스에서 반환된 점수에 적용되는 가중치다.
def query_index(query, fields=None, size=10):
data = spark.createDataFrame([(text,)], ('text',))
row = nlp_pipeline.transform(data).first()
query = row['normalized'][0]
if fields is None:
fields = [('normalized', 1), ('title', 10)]
headers = {
'Content-Type': 'application/json',
}
params = (
('pretty', ''), ('size', size)
)
data = {
"_source": ['title'],
"query": {
"multi_match": {
"query": query,
"fields": ['{}^{}'.format(f, b) for f, b in ...