Tags + Relevance

Discussion in 'Authors' Hangout' started by zankoo, Mar 9, 2023.

  1. zankoo

    zankoo Really Experienced CHYOA Backer

    Preface: I did a little searching for old threads on this topic, and didn't find what I was looking for ... though maybe that's kind of meta, since my issue is about how the search functions on the site work.

    When searching for content, I understand most of it, but I don't know how "relevance" functions as a criteria. Is there a formula? Is there an algorithm?

    Would love to learn more. Thanks!
     
  2. TheLowKing

    TheLowKing Really Really Experienced

    Ooo, good question! I'm also curious!
     
    Cuchuilain likes this.
  3. gene.sis

    gene.sis CHYOA Guru

    With "sort by" set to "Relevance," the search counts how often any search term is found in the relevant records.

    The higher the count, the earlier the result will be shown in the list.


    There are operators that can be used with search terms to modify how each term should be weighed.

    boolean mode operators
    e.g.
    +term
    -term
    >term
    <term
    "term"
    ~term
     
    Zingiber, Kinen and zankoo like this.
  4. zankoo

    zankoo Really Experienced CHYOA Backer

    This is a fantastic theory and system. And because this is the internet and I've been on the planet for a long time, I've learned to doubt everything everyone tells me.

    But if this is true, it's fascinating. Thank you.

    --

    EDIT: I just tested this a little bit, using the names of the two main characters of one of my stories, Abbie and Jake.

    When I searched for "Abbie" in stories using relevance, my story ("Always, Abbie") was the first hit. When I searched for "Jake" the same way, my story (in which Jake appears in hundreds of chapters, his name used probably thousands of times) does not appear at all.

    When I searched for "Abbie" in chapters using relevance, none of my chapters appeared at all, even though several of them have the name "Abbie" in the title, and almost all of them feature her name countless times.

    This is all to say that I think maybe I still don't understand.
     
  5. gene.sis

    gene.sis CHYOA Guru

    Well, the problem is that it doesn't search through all database columns of a story/chapter.
    I think the only columns are chapter title and tag for chapters, and title, subtitle, synopsis, and tag for stories.

    So if you search for
    abbie
    in chapters
    https://chyoa.com/search?q=abbie's&type=chapter&sort=relevance
    the first result is a chapter with "abbie" being part of the chapter title three times.
    In most chapter titles, the term is only used once, so these chapters get the same value assigned and only one result gets pushed to the top.

    If you search for
    jake abbie
    in chapters
    https://chyoa.com/search?q=jake+abbie&type=chapter
    the first result will be the one mentioned above as it has three hits, followed by chapters that got two hits.

    If you search for
    jake <abbie
    in chapters
    https://chyoa.com/search?q=jake+<abbie&type=chapter
    the term "abbie" gets deprioritized, though the result with the three hits will still be shown first.
    It is followed by results that contain jake twice. In the previous example, the search wouldn't make a difference between whether it was one abbie and one jake, two times abbie, or two times jake.


    The term "jake" doesn't appear in the mentioned columns at all.
    If you search for
    anything jokingly
    https://chyoa.com/search?q=anything jokingly&type=story&sort=relevance
    your story will appear at the top of the results.

    That search will return only three results that have "abbie" in the mentioned columns. In your story, it appears three times, so your story is at the top.
     
    Cuchuilain and zankoo like this.
  6. zankoo

    zankoo Really Experienced CHYOA Backer

    Ooh, this is very cool!

    Thank you so much for the extremely clear explanation! I really appreciate it.
     
    Cuchuilain and gene.sis like this.
  7. TheLowKing

    TheLowKing Really Really Experienced

    !??? How did I not know about this until now!?

    This changes everything! What do +term and ~term mean? Is the default search ORed? Is there a reference sheet for this somewhere?
     
    Cuchuilain likes this.
  8. gene.sis

    gene.sis CHYOA Guru

    Yes.

    "term" must be found in the search result.
    To do an AND search, you use
    +term1 +term2

    It is used in SQL implementation for full-text search in boolean mode.
    So you might find information about it in the manuals of the implementations.
    sql boolean full-text search operators


    Currently, there is still a bug that removes some of the operators when switching to the next page of search results. To prevent that from happening, you'd need to manually append the page information
    Code:
    &page=2
    to the link in the address bar in your browser.
     
    Zingiber and TheLowKing like this.
  9. TheLowKing

    TheLowKing Really Really Experienced

    Neat, thanks for the info!
     
    gene.sis likes this.
  10. Ewan-chan

    Ewan-chan Virgin

    I'm still confused on how to search with multiple tags? Do I put this in the search bar?
    "+tag1 +tag2"

    Or am I supposed to modify the URL itself?
     
    Last edited: Dec 18, 2023
  11. gene.sis

    gene.sis CHYOA Guru

    You put the search term "+term1 +term2" into CHYOA's search bar.
    This will work to get the first page of results. (Results 1 to 10)


    If you then click on page 2 to get results 11 to 20, it returns the results 11 to 20 for "term1 term2". Adding "&page=2" in the address bar is only necessary for results 11 and up.


    The search doesn't only search for "tags" but also in other fields.
    So the "tag" in your example would rather be "term" or "keyword"
     
  12. vyksin

    vyksin Virgin CHYOA Backer

    Another thing to keep in mind is the search here is great for meta data like tags, titles, authors, etc, but if you're just looking for raw content, you can constrain the public search engines with the "site:chyoa.com" parameter:
    https://www.google.com/search?q=Site:chyoa.com+Jake+abbie