Intelligent Search-Post

Enhancing content discovery with an intuitive approach, allowing users to explore content based on context rather than just keywords. With the semanticSearchPosts() function, the Amity SDK provides a LiveCollection of search results that prioritize relevance to the user. By utilizing advanced context recognition, semantic search enriches the discovery experience, helping users find content they might not have initially been aware of, thereby boosting community engagement.

This API supports searching through text and image posts. You can search the entire network or narrow your scope to a specific community feed or user feed.

Enable the Feature

To use this feature, please contact our support directly.

API Parameters

You can access this feature through the SDK or by making direct HTTP API calls. Below is an explanation of the function parameters:

Search Term

  • query: The search term. You can enter words, phrases, or sentences.

Supported Languages

The API supports searching in more than 100 languages.

Supported Languages
  • Afrikaans

  • Albanian

  • Amharic

  • Arabic

  • Armenian

  • Assamese

  • Azerbaijani

  • Bashkir

  • Basque

  • Belarusian

  • Bengali

  • Bosnian

  • Breton

  • Bulgarian

  • Burmese

  • Catalan

  • Cebuano

  • Chinese

  • Corsican

  • Croatian

  • Czech

  • Danish

  • Dhivehi

  • Dutch

  • English

  • Esperanto

  • Estonian

  • Faroese

  • Finnish

  • French

  • Galician

  • Georgian

  • German

  • Greek (Modern)

  • Gujarati

  • Haitian

  • Hausa

  • Hebrew

  • Hindi

  • Hungarian

  • Icelandic

  • Indonesian

  • Irish

  • Italian

  • Japanese

  • Javanese

  • Kannada

  • Kazakh

  • Khmer

  • Kirghiz

  • Kinyarwanda

  • Korean

  • Kurdish

  • Lao

  • Latin

  • Latvian

  • Lithuanian

  • Luxembourgish

  • Malagasy

  • Malay

  • Malayalam

  • Maltese

  • Marathi

  • Maori

  • Mongolian

  • Nepali

  • Norwegian

  • Norwegian Nynorsk

  • Occitan

  • Oriya

  • Punjabi

  • Pashto

  • Persian

  • Polish

  • Portuguese

  • Romanian

  • Russian

  • Sanskrit

  • Serbian

  • Sindhi

  • Sinhala

  • Slovak

  • Slovenian

  • Somali

  • Spanish

  • Sundanese

  • Swahili

  • Swedish

  • Tagalog

  • Tajik

  • Tamil

  • Tatar

  • Telugu

  • Thai

  • Tibetan

  • Turkish

  • Turkmen

  • Ukrainian

  • Urdu

  • Uzbek

  • Vietnamese

  • Welsh

  • Western Frisian

  • Xhosa

  • Yiddish

  • Yoruba

  • Zulu

Target Filtering

By default, the search will include all targets where the user has permission to view posts. However, you can narrow the search scope to a specific target by specifying both the targetType and targetId together.

  • targetType: Defines the type of target where the post was created, either community or user feed. This parameter is optional. If it is not provided, the system will attempt to search for posts in possible targets where the user has permission to read.

  • targetId: The ID of the designated target, i.e, community ID when targetType is community; user id when targetType is user.

  • dataTypes: ["text","image"]: This defines the types of content to search for. Users can customize it to search for only text, images, or both.

  • matchingOnlyParentPost: true: This excludes child posts from the search results when set to true, and includes child posts in the results when set to false.

Post Filtering

You can choose to filter specific post types based on parent-child relationships.

  • matchingOnlyParentPost

    • When set to true, only parent posts are included, excluding child posts from the search.

    • When set to false, both parent and child posts are included in the search.

  • postTypes: Filters posts by type. Currently supports filtering for text and image posts.

Example Use Cases

Search for Text Posts

When the user searches for "ice cream," the output may include posts ranked by their relevance score. For example:

Text Post 1st: "I love ice cream."
Text Post 2nd: "Ice cream is my favorite dessert."
Text Post 3rd: "Nothing beats a scoop of ice cream on a hot day!"
Text Post 4th: "I enjoy trying different types of pastries."
Text Post 5th: "Cooking is a great way to relax after a long day."

Search for Image Posts

When the user searches for "ice cream," the output may include posts ranked by their relevance score. For example:

The following code snippet demonstrates how to search for text and image posts across the entire network. Users can filter the results to display only text, images, or both, depending on their preference.

Search Result Score

This API returns a score for each item, ranging from 0 to 1. The score is calculated based on two factors—lexical and semantic—which are weighted differently.

  • Lexical score: contributes 30% of the total score. If a post contains text that matches the search term, it will receive a higher lexical score.

  • Semantic score: contributes 70% of the total score. The more relevant a post is to the search term in meaning, the higher its semantic score will be.

Filtering Results by Minimum Score

All matched items are included by default, even with a low score. However, you can adjust the minimum score filter based on the content and your specific use case. Any item with a score lower than the specified threshold will be excluded from the results.

Example search query - "Red Fruits"

  • Low Threshold (0.2): This shows various fruits, even those loosely related to the search term. For example, results could include apples, strawberries, and even unrelated fruits like bananas (not red).

  • Medium Threshold (0.5): This displays fruits moderately related to "red fruits," such as strawberries, red apples, and plums while excluding less relevant options like bananas or green grapes.

  • High Threshold (0.8): This filters results to show only highly relevant matches, such as cherries and raspberries while excluding unrelated fruits like bananas or green apples.

The API is available at Network Settings - Semantic Search (requires admin permission).

Limitations

  • The search function only considers the context of individual posts. It does not consider the relationship between parent posts, their replies, or comments.

  • Recent user activity is not considered when determining the relevance of search results.

  • Currently, the search only supports text and image posts; other post types are not included.

  • Real-time search suggestions while typing are not supported across all APIs.

Last updated