2015-08-24 1 views
4

Я хочу изменить систему подсчета очков в elasticsearch, чтобы избавиться от подсчета множественных появлений термина. Например, я хочу:elasticsearch отключить скорректированный коэффициент частоты

"техасский техасский техасский"

и

"техас"

выйти в тот же счет. Я нашел это отображение, elasticsearch сказал бы отключить подсчет термин частоты, но мои поиски не вышли в тот же счет:

"mappings":{ 
"business": { 
    "properties" : { 
     "name" : { 
      "type" : "string", 
      "index_options" : "docs", 
      "norms" : { "enabled": false}} 
     } 
    } 
} 

}

Любая помощь будет оценена, я не смог найти много информации об этом.

Edit:

Я добавляю свой код поиска и что получает возвращенное, когда я использую объяснить.

Мой код поиска:

Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", "escluster").build(); 
    Client client = new TransportClient(settings) 
    .addTransportAddress(new InetSocketTransportAddress("127.0.0.1", 9300)); 

    SearchRequest request = Requests.searchRequest("businesses") 
      .source(SearchSourceBuilder.searchSource().query(QueryBuilders.boolQuery() 
      .should(QueryBuilders.matchQuery("name", "Texas") 
      .minimumShouldMatch("1")))).searchType(SearchType.DFS_QUERY_THEN_FETCH); 

    ExplainRequest request2 = client.prepareIndex("businesses", "business") 

и когда я ищу с объяснения я получаю:

"took" : 14, 
    "timed_out" : false, 
    "_shards" : { 
    "total" : 3, 
    "successful" : 3, 
    "failed" : 0 
    }, 
    "hits" : { 
    "total" : 2, 
    "max_score" : 1.0, 
    "hits" : [ { 
     "_shard" : 1, 
     "_node" : "BTqBPVDET5Kr83r-CYPqfA", 
     "_index" : "businesses", 
     "_type" : "business", 
     "_id" : "AU9U5KBks4zEorv9YI4n", 
     "_score" : 1.0, 
     "_source":{ 
"name" : "texas" 
} 
, 
     "_explanation" : { 
     "value" : 1.0, 
     "description" : "weight(_all:texas in 0) [PerFieldSimilarity], result of:", 
     "details" : [ { 
      "value" : 1.0, 
      "description" : "fieldWeight in 0, product of:", 
      "details" : [ { 
      "value" : 1.0, 
      "description" : "tf(freq=1.0), with freq of:", 
      "details" : [ { 
       "value" : 1.0, 
       "description" : "termFreq=1.0" 
      } ] 
      }, { 
      "value" : 1.0, 
      "description" : "idf(docFreq=2, maxDocs=3)" 
      }, { 
      "value" : 1.0, 
      "description" : "fieldNorm(doc=0)" 
      } ] 
     } ] 
     } 
    }, { 
     "_shard" : 1, 
     "_node" : "BTqBPVDET5Kr83r-CYPqfA", 
     "_index" : "businesses", 
     "_type" : "business", 
     "_id" : "AU9U5K6Ks4zEorv9YI4o", 
     "_score" : 0.8660254, 
     "_source":{ 
"name" : "texas texas texas" 
} 
, 
     "_explanation" : { 
     "value" : 0.8660254, 
     "description" : "weight(_all:texas in 0) [PerFieldSimilarity], result of:", 
     "details" : [ { 
      "value" : 0.8660254, 
      "description" : "fieldWeight in 0, product of:", 
      "details" : [ { 
      "value" : 1.7320508, 
      "description" : "tf(freq=3.0), with freq of:", 
      "details" : [ { 
       "value" : 3.0, 
       "description" : "termFreq=3.0" 
      } ] 
      }, { 
      "value" : 1.0, 
      "description" : "idf(docFreq=2, maxDocs=3)" 
      }, { 
      "value" : 0.5, 
      "description" : "fieldNorm(doc=0)" 
      } ] 
     } ] 
     } 
    } ] 
    } 

Похоже, что все еще рассматривает частоту и частоту ДОК. Есть идеи? Извините за плохое форматирование, я не знаю, почему он выглядит таким гротескным.

Править:

Мой код из поиска браузера http://localhost:9200/businesses/business/_search?pretty=true&qname=texas является:

{ 
    "took" : 2, 
    "timed_out" : false, 
    "_shards" : { 
    "total" : 3, 
    "successful" : 3, 
    "failed" : 0 
    }, 
    "hits" : { 
    "total" : 4, 
    "max_score" : 1.0, 
    "hits" : [ { 
     "_index" : "businesses", 
     "_type" : "business", 
     "_id" : "AU9YcCKjKvtg8NgyozGK", 
     "_score" : 1.0, 
     "_source":{"business" : { 
"name" : "texas texas texas texas" } 
} 
    }, { 
     "_index" : "businesses", 
     "_type" : "business", 
     "_id" : "AU9YateBKvtg8Ngyoy-p", 
     "_score" : 1.0, 
     "_source":{ 
"name" : "texas" } 

    }, { 
     "_index" : "businesses", 
     "_type" : "business", 
     "_id" : "AU9YavVnKvtg8Ngyoy-4", 
     "_score" : 1.0, 
     "_source":{ 
"name" : "texas texas texas" } 

    }, { 
     "_index" : "businesses", 
     "_type" : "business", 
     "_id" : "AU9Yb7NgKvtg8NgyozFf", 
     "_score" : 1.0, 
     "_source":{"business" : { 
"name" : "texas texas texas" } 
} 
    } ] 
    } 
} 

Он находит все 4 объекта у меня есть там и есть их все тот же счет. Когда я запускаю мой Java API поиска с объяснения я получаю:

{ 
    "took" : 2, 
    "timed_out" : false, 
    "_shards" : { 
    "total" : 3, 
    "successful" : 3, 
    "failed" : 0 
    }, 
    "hits" : { 
    "total" : 2, 
    "max_score" : 1.287682, 
    "hits" : [ { 
     "_shard" : 1, 
     "_node" : "BTqBPVDET5Kr83r-CYPqfA", 
     "_index" : "businesses", 
     "_type" : "business", 
     "_id" : "AU9YateBKvtg8Ngyoy-p", 
     "_score" : 1.287682, 
     "_source":{ 
"name" : "texas" } 
, 
     "_explanation" : { 
     "value" : 1.287682, 
     "description" : "weight(name:texas in 0) [PerFieldSimilarity], result of:", 
     "details" : [ { 
      "value" : 1.287682, 
      "description" : "fieldWeight in 0, product of:", 
      "details" : [ { 
      "value" : 1.0, 
      "description" : "tf(freq=1.0), with freq of:", 
      "details" : [ { 
       "value" : 1.0, 
       "description" : "termFreq=1.0" 
      } ] 
      }, { 
      "value" : 1.287682, 
      "description" : "idf(docFreq=2, maxDocs=4)" 
      }, { 
      "value" : 1.0, 
      "description" : "fieldNorm(doc=0)" 
      } ] 
     } ] 
     } 
    }, { 
     "_shard" : 1, 
     "_node" : "BTqBPVDET5Kr83r-CYPqfA", 
     "_index" : "businesses", 
     "_type" : "business", 
     "_id" : "AU9YavVnKvtg8Ngyoy-4", 
     "_score" : 1.1151654, 
     "_source":{ 
"name" : "texas texas texas" } 
, 
     "_explanation" : { 
     "value" : 1.1151654, 
     "description" : "weight(name:texas in 0) [PerFieldSimilarity], result of:", 
     "details" : [ { 
      "value" : 1.1151654, 
      "description" : "fieldWeight in 0, product of:", 
      "details" : [ { 
      "value" : 1.7320508, 
      "description" : "tf(freq=3.0), with freq of:", 
      "details" : [ { 
       "value" : 3.0, 
       "description" : "termFreq=3.0" 
      } ] 
      }, { 
      "value" : 1.287682, 
      "description" : "idf(docFreq=2, maxDocs=4)" 
      }, { 
      "value" : 0.5, 
      "description" : "fieldNorm(doc=0)" 
      } ] 
     } ] 
     } 
    } ] 
    } 
} 
+0

Несоответствие, скорее всего, связано с 'doc frequency', а не' term fre Вы используете [search_type = dfs_query_then_fetch] (https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-search-type.html#query-then-fetch?q=query_then_fech). Если это не поможет установить параметр 'explain = true' в запросе, чтобы увидеть пробой в подсчете – keety

+0

, я переключил его на dfs_query_then_fetch, но это не сработало. Я отправлю свой код и объясню результаты в течение второго – Chadvador

+0

. Могли бы вы также отправить запрос? – keety

ответ

1

Похоже, один не может переопределить index options для поля после того, как поле было начальное множество в отображении

Пример:

put test 
put test/business/_mapping 
{ 

     "properties": { 
     "name": { 
      "type": "string", 
      "index_options": "freqs", 
      "norms": { 
       "enabled": false 
      } 
     } 
     } 

} 
put test/business/_mapping 
{ 

     "properties": { 
     "name": { 
      "type": "string", 
      "index_options": "docs", 
      "norms": { 
       "enabled": false 
      } 
     } 
     } 

} 
get test/business/_mapping 

    { 
    "test": { 
     "mappings": { 
     "business": { 
      "properties": { 
       "name": { 
        "type": "string", 
        "norms": { 
        "enabled": false 
        }, 
        "index_options": "freqs" 
       } 
      } 
     } 
     } 
    } 
} 

Вам нужно будет воссоздать индекс, чтобы забрать новое изображение

+0

Ну, это неловко, это было мое собственное глупость, я тестировал только с помощью моего браузера с помощью команды: http: // localhost: 9200/business/_search? pretty = true & explain = true & q = texas, после того как я изменил его на «qname = texas», он работает, оценки - это одна и та же. Так почему же он не работает с моим API-интерфейсом java, где кажется, что я ищу поле имени? – Chadvador

+0

вы можете вставить весь фрагмент или лучше ответ с объяснением, установленным в java-клиенте. – keety

+0

Прошу прощения, я не уверен, как установить его в javaAPI, это не похоже на вариант SearchRequest. Я буду обновлять свой OP кодом. – Chadvador

Смежные вопросы