Jump to content

Featured Replies

Posted

I want to search a title in a database to make sure the record is not already there.   I found the different search types I can do:

    "contenttypes": [
        "core_statuses_status",
        "calendar_event",
        "cms_pages_pageitem",
        "cms_records1",
        "cms_records2",
        "forums_topic",
        "nexus_package_item",
        "links_link"
    ]

What contenttype do I use if I want to search database #3?

Edited by Elon Report

Solved by Sonya*

Go to solution
  • Elon Report changed the title to How do I search Databases via API?

Ive moved this to our developer forum for you, which is better placed to get you the answers you need 🙂 

Are you using OAuth tokens? If so, the member you're connecting as most likely doesn't have permission to see the database.

  • Author
7 hours ago, Stuart Silvester said:

Are you using OAuth tokens? If so, the member you're connecting as most likely doesn't have permission to see the database.

No, I am using REST API.   I tried cms_records3, but that did not work.   

  • Author

REST API keys, instead of the OAuth.

 

12 hours ago, Elon Report said:

search database #3?

Are you sure that there's a DB 3? If yes, is it placed on a frontend page?

  • Author
11 minutes ago, Daniel F said:

 

Are you sure that there's a DB 3? If yes, is it placed on a frontend page?

Yes, there is database 3.   It is not placed on a page - do I need to do that to access the data?

Is search enabled for the database? 

Could contain: Text

  • Author

Yes it is.

What contenttype am I looking for if I want to search database 3?    Is it supposed to be cms_records3 or something else?

  • Solution
55 minutes ago, Elon Report said:

 It is not placed on a page - do I need to do that to access the data?

You need a page. The database itself has no url, the page has. If there is no URL, nothing can be accessed or searched.

  • Author
58 minutes ago, Sonya* said:

You need a page. The database itself has no url, the page has. If there is no URL, nothing can be accessed or searched.

That was the solution!   I was able to create records without a url though.

For anyone else that stumbles with this issue:

My database id is 3.   My new page id is 4.

The contenttype is cms_records3

Thanks all.

Edited by Elon Report

  • Author

OK, I am now trying to search actual data, and running into an issue.  Was going to start a new thread but this one was at the top.  🙂

I have a database (#4) on a page, and I am able to upload a record to it.   I can see it on the page. However, I always get no results found via the api.

{{base_url}}?/core/search&q=2&type=cms_records4
{
    "page": 1,
    "perPage": 25,
    "totalResults": 0,
    "totalPages": 0,
    "results": []
}

The title is "2".  I've tried playing with variables but nothing gets returned when there are no filters at all!

Edited by Elon Report

Do you use elastic or MySQL search? MySQL cannot search by one character. Elastic - does.

  • Author

It is MySQL - but I will look into a elastic server!

That was not the problem.  I changed the title to text, and made the value 00002

Searching produces the same result - none.

Have you rebuilt search index in ACP? Take a look at core_search_index in your database. Can you see your record there?

  • Author
1 hour ago, Sonya* said:

Have you rebuilt search index in ACP? Take a look at core_search_index in your database. Can you see your record there?

Rebuilding solved the problem.  Thanks for the extra troubleshooting tip as well!

Recently Browsing 0

  • No registered users viewing this page.