117 'tableName' => static::getTableNameWord2Location(),
118 'exactFields' => array(
119 'LOCATION_ID' => array(
'data_type' =>
'integer'),
120 'WORD_ID' => array(
'data_type' =>
'integer')
122 'parameters' => array(
128 'entityName' =>
'\Bitrix\Sale\Location\Search\WordTable',
129 'exactFields' => array(
132 'parameters' => array(
133 'mtu' => static::MTU,
134 'autoIncrementFld' =>
'ID',
135 'CALLBACKS' => array(
136 'ON_BEFORE_FLUSH' => array($this,
'onBeforeDictionaryFlush')
142 'tableName' => static::getTableNamePositionTemporal(),
143 'exactFields' => array(
144 'WORD_ID' => array(
'data_type' =>
'integer'),
145 'POSITION' => array(
'data_type' =>
'integer')
147 'parameters' => array(
165 $dbConnection = Main\HttpApplication::getConnection();
167 Helper::dropTable(static::getTableName());
169 $binary = ToLower($dbConnection->getType()) ==
'mysql' ?
'binary' :
'';
172 Main\HttpApplication::getConnection()->query(
"create table ".static::getTableName().
" (
174 ID ".Helper::getSqlForDataType(
'int').
" not null ".Helper::getSqlForAutoIncrement().
" primary key,
175 WORD ".Helper::getSqlForDataType(
'varchar', 50).
" ".$binary.
" not null,
176 POSITION ".Helper::getSqlForDataType(
'int').
" default '0'
179 Helper::addAutoIncrement(static::getTableName());
181 Helper::createIndex(static::getTableName(),
'TMP', array(
'WORD'),
true);
182 Helper::dropTable(static::getTableNameWord2Location());
185 Main\HttpApplication::getConnection()->query(
"create table ".static::getTableNameWord2Location().
" (
187 LOCATION_ID ".Helper::getSqlForDataType(
'int').
" not null,
188 WORD_ID ".Helper::getSqlForDataType(
'int').
" not null,
190 primary key (LOCATION_ID, WORD_ID)
193 Helper::dropTable(static::getTableNamePositionTemporal());
195 $dbConnection->query(
"create table ".static::getTableNamePositionTemporal().
" (
196 WORD_ID ".Helper::getSqlForDataType(
'int').
" not null,
197 POSITION ".Helper::getSqlForDataType(
'int').
" default '0'
281 $res = Location\Name\LocationTable::getList(array(
286 'filter' => static::getFilterForInitData(array(
287 'TYPES' => $this->procData[
'ALLOWED_TYPES'],
288 'LANGS' => $this->procData[
'ALLOWED_LANGS']
290 'order' => array(
'LOCATION_ID' =>
'asc'),
291 'limit' => static::STEP_SIZE,
292 'offset' => $this->procData[
'OFFSET']
296 while($item = $res->fetch())
298 if($item[
'NAME'] <>
'')
300 if($this->procData[
'CURRENT_LOCATION'] != $item[
'LOCATION_ID'])
302 $this->procData[
'CURRENT_LOCATION_WORDS'] = array();
305 $this->procData[
'CURRENT_LOCATION'] = $item[
'LOCATION_ID'];
307 $words = static::parseString($item[
'NAME']);
309 foreach($words as $k => &$word)
311 $wordHash = md5($word);
314 if(isset($this->dictionaryIndex[$wordHash]))
316 $wordId = $this->dictionaryIndex[$wordHash];
320 $wordId = static::getIdByWord($word);
323 if($wordId ===
false)
325 $wordId = $this->dictionaryInserter->insert(array(
328 $this->dictionaryIndex[$wordHash] = $wordId;
331 if($wordId !==
false && !isset($this->procData[
'CURRENT_LOCATION_WORDS'][$wordId]))
333 $this->procData[
'CURRENT_LOCATION_WORDS'][$wordId] =
true;
335 $this->word2LocationInserter->insert(array(
336 'LOCATION_ID' => intval($item[
'LOCATION_ID']),
337 'WORD_ID' => intval($wordId)
346 $this->procData[
'OFFSET'] += static::STEP_SIZE;
348 $this->dictionaryInserter->flush();
349 $this->word2LocationInserter->flush();
356 $res = Main\HttpApplication::getConnection()->query(
357 Main\HttpApplication::getConnection()->getSqlHelper()->getTopSql(
"select ID, WORD from ".static::getTableName().
" order by WORD asc, ID asc", self::STEP_SIZE, intval($this->procData[
'OFFSET']))
361 while($item = $res->fetch())
363 $this->procData[
'POSITION']++;
365 $this->dictionaryResorter->insert(array(
366 'WORD_ID' => $item[
'ID'],
367 'POSITION' => $this->procData[
'POSITION']
373 $this->procData[
'OFFSET'] += static::STEP_SIZE;
375 $this->dictionaryResorter->flush();