\seekquarry\yioop\modelsSearchverticalsModel

This class manages the editing of search verticals. This includes allowing one to specify a search result should be filtered from the results of a query, it also includes alterning the title and description of a result from how it is stored in a particular index and it finally includes creating, updating, deleting knowledge wiki results To handle these activities this class leverages the existing group wiki system of Yioop. Edited and filtered search results correspond to group feed entries in a Search Group. Edited knowledge wiki entries correspond to wiki entires in the Search Group.

Summary

Methods
Properties
Constants
isFiltered()
lastChange()
hashIntPair()
getQueryMap()
setQueryMap()
getKnowledgeWiki()
updateUrlResult()
getEditedPageResult()
incorporateEditedPageResults()
$memory_filter
$last_change
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$memory_filter

$memory_filter :array

Used to hold an in_memory cache of what search results are to be filtered

Type

array

$last_change

$last_change :integer

Used to hold an in memory copy of the timestamp of the last time a search result was altered

Type

integer

Methods

isFiltered()

isFiltered(string  $url,boolean  $compute_hash_key = false): boolean

Check if a URL is supposed to be filtered from search results.

Parameters

string $url

to see if filtered

boolean $compute_hash_key

flag to control hashing before computing GROUP_ITEM lookup. Sometimes $url might be already the hash of a URL to check if filtered

Returns

boolean —

whether the url should be filtered from search results or not

lastChange()

lastChange(): integer

Returns the timestamp of the last time any of the search results were edited.

Returns

integer —

timestamp of last edited search results

hashIntPair()

hashIntPair(  $input,boolean  $compute_hash = true)

Computes a hash value as an ordered pair of ints. Used to store filtered urls into the GROUP_ITEM table. In this situation, the ordered pair is used later for the PARENT_ID and USER_ID in the (both of which have indexes) Search group look-up.

@param string an input to be hash to a pair of integers

Parameters

$input
boolean $compute_hash

flag to chheck if a crawlHash is done before converting the result to an ordered pair. In some situations the url or host of the url has already been hashed so don't want to hash it again. @return array [int, int] that corresponds to the hash of the input to keep postgres happy (no unsigned ints) we make the value of this function signed

getQueryMap()

getQueryMap(  $query,  $locale_tag)

Parameters

$query
$locale_tag

setQueryMap()

setQueryMap(  $query,  $map_urls,  $locale_tag)

Parameters

$query
$map_urls
$locale_tag

getKnowledgeWiki()

getKnowledgeWiki(string  $query,  $locale_tag,  $edit_mode = false)

Get the knowledge wiki page corresponding to a search query.

This is used in wiki read mode for search result verticals or edit mode (the wiki info is not pre-parsed) for editing the knowledge wiki page.

Parameters

string $query

to get knowledge wiki results for @param string $locale the locale tag language that one want the results for @param bool $edit_mode whether the wiki page should be pre-parsed (suitable for display in query results) or left unparsed (suitable for editing). @return array knowledge wiki page info

$locale_tag
$edit_mode

updateUrlResult()

updateUrlResult(integer  $id,integer  $type,string  $url,string  $title,string  $description): mixed

Updates the title and description text that will be presented when a given url appears in search results

Parameters

integer $id

if the url has been edited previous then the id of the group item with the edit. If this is 0/empty then a new group item for the edit is created. If -1 then deletes the entry

integer $type

either SEARCH_FILTER_GROUP_ITEM or SEARCH_EDIT_GROUP_ITEM

string $url

to change search result for

string $title

new title for search result

string $description

new snippet text for search result

Returns

mixed —

integer id of edited/created result or if used to delete then false

getEditedPageResult()

getEditedPageResult(string  $url): mixed

Returns any edited search result associated with a url

Parameters

string $url

url to get edit search results for

Returns

mixed —

either false if no edited search results or an associative array containing edited results if they exist

incorporateEditedPageResults()

incorporateEditedPageResults(array  $results,array  $words = null,integer  $description_length = self::DEFAULT_DESCRIPTION_LENGTH): array

Given an array page summaries, for each summary check if the url corresponds to a search result that was human edited, if so, replace and format it.

Parameters

array $results

web pages summaries (these in turn are arrays!)

array $words

keywords (typically what was searched on)

integer $description_length

length of the description

Returns

array —

summaries which have been snippified and bold faced