• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.2 Latest
Buy Hosting

db search not only title and post but also tag name

Scheduled Pinned Locked Moved Plugin Development
searchsearch enginetagstagindexing issue
4 Posts 2 Posters 385 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Sebastián CisnerosS Offline
    Sebastián CisnerosS Offline
    Sebastián Cisneros Gamers
    wrote on last edited by Sebastián Cisneros
    #1

    So, let's say I create a new Topic, and set as tag for that topic "development" . In the title and in the body I don't write the word "development'.

    If I search 'development' that topic wont appear in the results.

    How can I make it that the search results also searches in the tags, or how can I make the tags to be indexed so the search finds that topic?

    1 Reply Last reply
    0
  • barisB Offline
    barisB Offline
    <baris> NodeBB
    wrote on last edited by
    #2

    Once https://github.com/NodeBB/NodeBB/issues/9976 is done you can do something like below using filter:search.query

    myPlugin.filterSearchQuery = async (hookData) => {
    		if (hookData.index === 'topic') {
    			// split the search term into multiple tags 
    			const tags = String(hookData.content).split(' ');
    			
    			const tidsArray = await Promise.all(tags.map(async (tag) => {
    				// for each tag get the topics tagged by it
    				if (hookData.cids.length) {
    					return await Topics.getTagTidsByCids(tag, hookData.cids, 0, -1);
    				}
    				return await Topics.getTagTids(tag, 0, -1);
    			}));
    			hookData.ids = hookData.ids.concat(_.uniq(_.flatten(tidsArray)));
    		} 
    		return hookData;
    	};
    

    This will include all topics tagged by your search query in the results of the actual search. However this won't work until we close the above issue.

    Sebastián CisnerosS 1 Reply Last reply
    1
  • Sebastián CisnerosS Offline
    Sebastián CisnerosS Offline
    Sebastián Cisneros Gamers
    replied to <baris> on last edited by
    #3

    @baris another "solution" / hack I though is this:

    to hook into the post save action/filter , and add at the end of the body of the post a div or parragraph like this

    '<p class="list-of-tags">tag1, tag2, tag3</p>'
    

    and hide by css this element

    this way the search engine may index the tags, right?

    1 Reply Last reply
    0
  • barisB Offline
    barisB Offline
    <baris> NodeBB
    wrote on last edited by
    #4

    Yeah if you put the tags in the content of the posts they will get indexed and search should find them, keep in mind the body of the posts are searched when you search in "posts" so if you are only searching for titles they wont show up.

    1 Reply Last reply
    1

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development