Skip to content

Commit

Permalink
[DOCS Added new hierarchical field for Coveo (#27569)
Browse files Browse the repository at this point in the history
### Details:
 - *item1*
 - *...*

### Tickets:
 - *ticket-id*
  • Loading branch information
akopytko authored Nov 15, 2024
1 parent 651a51c commit 4cc7ef0
Show file tree
Hide file tree
Showing 3 changed files with 356 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,24 @@ def process_coveo_meta(meta, url, link):

for namespace, values in meta:
namespace_element = ET.SubElement(url, namespace)
loc_element = url.find("loc")

for tag_name, tag_value in values.items():
if tag_name == 'ovdoctype':
processed_link = process_link(link)
ET.SubElement(namespace_element, tag_name).text = processed_link
else:
ET.SubElement(namespace_element, tag_name).text = process_link(link)
elif tag_name == 'ovcategory' and loc_element is not None:
ET.SubElement(namespace_element, tag_name).text = extract_link(loc_element.text)
elif tag_name == 'ovversion':
ET.SubElement(namespace_element, tag_name).text = tag_value

def process_link(link):
if '/' in link:
return link.split('/')[0].replace("-", " ")
return link.split('.html')[0].replace("-", " ")
return link.split('.html')[0].replace("-", " ")

def extract_link(link):
path = link.split("://")[-1]
segments = path.split('/')[1:]
if segments and segments[-1].endswith('.html'):
segments = segments[:-1]
return '|'.join(segments)
Loading

0 comments on commit 4cc7ef0

Please sign in to comment.