Movable Type: Specify only one keyword from MTEntryKeywords - movabletype

I have several keywords (1~3 words) stored in <MTEntryKeywords> field separated by commas.
I want to take out the first keyword from MTEntryKeywords.
Example 1:
In the Keywords field I have entered: gadgets,phone,apple,
Want to display: gadgets
Example 2:
In the Keywords field I have entered: food,coffee,apple,
Want to display: food
Any ideas?

This is untested, but something like this should do the trick (assuming you're using a recent enough version of MT)
<mt:entrykeywords regex_replace="/^([^,]+)(,.*)?$/","$1">
Basically, the regular expression there is saying "keep only everything up to, but not including, the first comma".

Related

How can I easily get search context around search term with Typesense?

I currently use Typesense to search in an HTML database. When I search for a term, I would like to retrieve N characters before and N characters after the term found in search.
For example, I search for "query" and this is the sentence that matches:
Let's repeat the query we made earlier with a group_by parameter
I would like to easy retrieve a fixed number of letters (or words) before and after the term to show it in a presumably small area where the search results is retrieved, without breaking any words.
For this particular example, I would be showing:
..repeat the query we made earlier..
Is there a feature like this in Typesense?
I have checked Typesense's documents, without any luck.
The feature you're referring to is called snippets/highlights and it's enabled by default. You can control how many words are returned on either side of the matched text using the highlight_affix_num_tokens search parameter, documented under the table here: https://typesense.org/docs/0.23.1/api/search.html#results-parameters
highlight_affix_num_tokens
The number of tokens that should surround the highlighted text on each side. This controls the length of the snippet.

Exclude tag in flickr.photos.search

According to the docs for flickr.photos.search (https://secure.flickr.com/services/api/flickr.photos.search.html), the 'tags' variable is a comma-delimited list of tags. It also says, "You can exclude results that match a term by prepending it with a - character."
I keep trying to do something like "tags=cat,-catalog", but that doesn't give me any results. What's the proper format for excluding results in the REST query?

FTSearch that looks for '-'

does anybody know if there is a possibility to search for '-' using FTSearch?
Set col = db.ftsearch({ [services] = "-"}, 0)
dat requests does not work and instead says:
Notes error: Full text error; see log for more information (
[services] = "-")
Short answer is no.
The full text search treats most symbol characters as a white space. The exception is if the search term itself is wrapped in quotes.
The FT search engine also uses 3-gram for searching. This means that less then 3 characters will not return the results you expect. White spaces would be treated in that search, but only in the context of the found text.
For example: "ce " would find "space " but not "space." or "space" or "spaced".
If you are looking for the field that only contains "-", then a better solution is to create a view with a column containing that field value, and/or filter by that field being that value.
Looks like you are trying to do a full text search in a view? You probably would get better response time and less server impact to use #Formula language if you are working with a view.
I try to keep away on doing full text searches on the entire database. You can use a search on a view collection for faster results. There is no restriction on how many views you can have in a db. There is a cost for everything though. There are so many little tricks that can be used to get better results. Please give us more details on what you are trying to do.

Expression Engine - Channel Fields Search

I'm fairly new to Expression Engine and I feel this is a really simple question, I just can't find a straight-forward answer from the documentation.
I have a list of restaurants and an alphabetized menu (A B C D etc...)
I want to search only he listings that start with the letter "A".
In a tradiational MySQL search that's be WHERE Title LIKE 'A%'
Any ideas?
I do not believe the Channel Entries module's search parameter allows LIKE matching.
You'll save time by grabbing the Low Alphabet module in this specific case for sure.
Expression Engine doesn't have an exact "LIKE" option but they do have something similar.
I can search a field to see if it "contains" a string but there isn't anything specifically to determine if it starts with or ends with a specific string (such as would be easily available in MySQL).
I ended up doing the "contains" search parameter and then excluded any results within the exp:channel:entries looping that didn't match my exact criteria.

Solr title search failing

I am indexing the title field for few products in Solr.
But when I am searching, I am not getting those titles in response.
For eg. I am storing following as title : Baboons Typing Tshirt
But when I am searching following I am not getting any result !!!
1)title:Baboons
2)title:(Baboons Typing Tshirt)
3)title:(Baboons*)
On the otherhand, if I am searching like this, I am getting lot of results
1)title:(Tshirt)
I have indexed many titles containing word Tshirt but I want to search a specific title which is failing..!!
I dont know whether Solr is ignoring first words, or it is doing something random.
My Question is basically: If I have a search title with lots of words, I will like to match it with the title which contains maximum common terms.
How to do it?
Thanks
Solr works like that by itself. You don't have to change anything.
You have to be careful how you set up your fields in schema.xml, i.e. how analysis is done.
You can use Solr's admin > Analysis interface to see how exactly your title field (when indexing) and query (when searching) is processed (tokenized, transformed).
Remember, match, in order to occur, requires identical word (case and everything) on both sides (index & query).
To open your index and see how Solr has actually indexed your data, use Luke.

Resources